mirror of
https://git.cloudron.io/cloudron/syncthing-app
synced 2026-04-24 11:24:59 +00:00
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:
@@ -12,5 +12,6 @@
|
|||||||
"chromedriver": "^147.0.1",
|
"chromedriver": "^147.0.1",
|
||||||
"mocha": "^11.7.5",
|
"mocha": "^11.7.5",
|
||||||
"selenium-webdriver": "^4.41.0"
|
"selenium-webdriver": "^4.41.0"
|
||||||
}
|
},
|
||||||
|
"type": "module"
|
||||||
}
|
}
|
||||||
|
|||||||
24
test/test.js
24
test/test.js
@@ -1,20 +1,16 @@
|
|||||||
#!/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 timers from 'node:timers/promises';
|
||||||
|
import { Builder, By, until } from 'selenium-webdriver';
|
||||||
|
import { Options } from 'selenium-webdriver/chrome';
|
||||||
|
|
||||||
/* global it, xit, describe, before, after, afterEach */
|
/* global it, xit, describe, before, after, afterEach */
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
require('chromedriver');
|
|
||||||
|
|
||||||
const execSync = require('child_process').execSync,
|
|
||||||
assert = require('node:assert/strict'),
|
|
||||||
fs = require('fs'),
|
|
||||||
path = require('path'),
|
|
||||||
timers = require('timers/promises'),
|
|
||||||
{ 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);
|
||||||
@@ -27,7 +23,7 @@ describe('Application life cycle test', function () {
|
|||||||
const TEST_TIMEOUT = 30000;
|
const TEST_TIMEOUT = 30000;
|
||||||
const FOLDER = 'xmf'; // keep this small. long folder names fail in automation, not sure why
|
const FOLDER = 'xmf'; // keep this small. long folder names fail in automation, not sure why
|
||||||
const SYNC_PORT = 22001;
|
const SYNC_PORT = 22001;
|
||||||
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 adminUsername = 'admin', adminPassword = 'changeme';
|
const adminUsername = 'admin', adminPassword = 'changeme';
|
||||||
|
|||||||
Reference in New Issue
Block a user