mirror of
https://git.cloudron.io/cloudron/minio-app
synced 2026-05-02 23:25:50 +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:
+2
-1
@@ -14,5 +14,6 @@
|
||||
"mocha": "^11.7.4",
|
||||
"selenium-webdriver": "^4.36.0",
|
||||
"superagent": "^10.2.3"
|
||||
}
|
||||
},
|
||||
"type": "module"
|
||||
}
|
||||
|
||||
+12
-16
@@ -1,21 +1,17 @@
|
||||
#!/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 superagent from 'superagent';
|
||||
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 */
|
||||
|
||||
'use strict';
|
||||
|
||||
require('chromedriver');
|
||||
|
||||
const execSync = require('child_process').execSync,
|
||||
assert = require('node:assert/strict'),
|
||||
fs = require('fs'),
|
||||
path = require('path'),
|
||||
superagent = require('superagent'),
|
||||
timers = require('timers/promises'),
|
||||
{ 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);
|
||||
@@ -27,7 +23,7 @@ describe('Application life cycle test', function () {
|
||||
const LOCATION = process.env.LOCATION || 'test';
|
||||
const TEST_TIMEOUT = parseInt(process.env.TIMEOUT, 10) || 30000;
|
||||
const BUCKET = 'cloudrontestbucket';
|
||||
const EXEC_ARGS = { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' };
|
||||
const EXEC_ARGS = { cwd: path.resolve(import.meta.dirname, '..'), stdio: 'inherit' };
|
||||
|
||||
let browser, app;
|
||||
let rootPassword;
|
||||
@@ -139,7 +135,7 @@ describe('Application life cycle test', function () {
|
||||
}
|
||||
|
||||
async function changeAdminCredentials() {
|
||||
let data = fs.readFileSync(path.join(__dirname, '../env.sh.template'), 'utf8');
|
||||
let data = fs.readFileSync(path.join(import.meta.dirname, '../env.sh.template'), 'utf8');
|
||||
data += '\nexport MINIO_ROOT_USER=minioakey\nexport MINIO_ROOT_PASSWORD=minioskey\n';
|
||||
fs.writeFileSync('/tmp/env.sh', data);
|
||||
execSync(`cloudron push --app ${app.id} /tmp/env.sh /app/data/env.sh`, EXEC_ARGS);
|
||||
|
||||
Reference in New Issue
Block a user