diff --git a/test/package.json b/test/package.json index 127dfe1..e319818 100644 --- a/test/package.json +++ b/test/package.json @@ -14,5 +14,6 @@ }, "dependencies": { "chromedriver": "^146.0.5" - } + }, + "type": "module" } diff --git a/test/test.js b/test/test.js index 8aa1c76..5ff4407 100755 --- a/test/test.js +++ b/test/test.js @@ -1,6 +1,13 @@ #!/usr/bin/env node -/* jshint esversion: 8 */ +import 'chromedriver'; +import { execSync } from 'node:child_process'; +import assert from 'node:assert/strict'; +import fs from 'node:fs'; +import path from 'node:path'; +import { Builder, By, until } from 'selenium-webdriver'; +import { Options } from 'selenium-webdriver/chrome'; + /* global describe */ /* global before */ /* global after */ @@ -8,17 +15,6 @@ /* global it */ /* global xit */ -'use strict'; - -require('chromedriver'); - -const execSync = require('child_process').execSync, - assert = require('node:assert/strict'), - fs = require('fs'), - path = require('path'), - { Builder, By, until } = require('selenium-webdriver'), - { Options } = require('selenium-webdriver/chrome'); - if (!process.env.USERNAME || !process.env.PASSWORD) { console.log('USERNAME and PASSWORD env vars need to be set'); process.exit(1); @@ -29,7 +25,7 @@ describe('Application life cycle test', function () { const LOCATION = process.env.LOCATION || 'test'; const TEST_TIMEOUT = parseInt(process.env.TIMEOUT) || 10000; - const EXEC_ARGS = { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }; + const EXEC_ARGS = { cwd: path.resolve(import.meta.dirname, '..'), stdio: 'inherit' }; let browser, app; const username = process.env.USERNAME; @@ -137,7 +133,7 @@ describe('Application life cycle test', function () { it('has registration open', checkRegistration.bind(null, 'none')); let testPassword; it('create a user with CLI', function () { - const output = execSync('cloudron exec --app ' + LOCATION + ' -- bin/tootctl accounts create test --email=test@cloudron.io', { cwd: path.resolve(__dirname, '..'), encoding: 'utf8' }); + const output = execSync('cloudron exec --app ' + LOCATION + ' -- bin/tootctl accounts create test --email=test@cloudron.io', { cwd: path.resolve(import.meta.dirname, '..'), encoding: 'utf8' }); console.log(output); testPassword = output.slice(output.indexOf('New password: ') + 'New password: '.length).trim(); console.log(testPassword);