test: convert test to ESM
Replace CommonJS require() with ESM imports, add "type": "module" to test/package.json, remove 'use strict' and jshint directives, replace __dirname with import.meta.dirname. Made-with: Cursor
This commit is contained in:
+2
-1
@@ -14,5 +14,6 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"chromedriver": "^146.0.5"
|
"chromedriver": "^146.0.5"
|
||||||
}
|
},
|
||||||
|
"type": "module"
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-14
@@ -1,6 +1,13 @@
|
|||||||
#!/usr/bin/env node
|
#!/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 describe */
|
||||||
/* global before */
|
/* global before */
|
||||||
/* global after */
|
/* global after */
|
||||||
@@ -8,17 +15,6 @@
|
|||||||
/* global it */
|
/* global it */
|
||||||
/* global xit */
|
/* 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) {
|
if (!process.env.USERNAME || !process.env.PASSWORD) {
|
||||||
console.log('USERNAME and PASSWORD env vars need to be set');
|
console.log('USERNAME and PASSWORD env vars need to be set');
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
@@ -29,7 +25,7 @@ describe('Application life cycle test', function () {
|
|||||||
|
|
||||||
const LOCATION = process.env.LOCATION || 'test';
|
const LOCATION = process.env.LOCATION || 'test';
|
||||||
const TEST_TIMEOUT = parseInt(process.env.TIMEOUT) || 10000;
|
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;
|
let browser, app;
|
||||||
const username = process.env.USERNAME;
|
const username = process.env.USERNAME;
|
||||||
@@ -137,7 +133,7 @@ describe('Application life cycle test', function () {
|
|||||||
it('has registration open', checkRegistration.bind(null, 'none'));
|
it('has registration open', checkRegistration.bind(null, 'none'));
|
||||||
let testPassword;
|
let testPassword;
|
||||||
it('create a user with CLI', function () {
|
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);
|
console.log(output);
|
||||||
testPassword = output.slice(output.indexOf('New password: ') + 'New password: '.length).trim();
|
testPassword = output.slice(output.indexOf('New password: ') + 'New password: '.length).trim();
|
||||||
console.log(testPassword);
|
console.log(testPassword);
|
||||||
|
|||||||
Reference in New Issue
Block a user