mirror of
https://github.com/ether/etherpad-lite.git
synced 2026-07-26 03:24:02 +00:00
test(container): convert loadSettings + api/pad to TypeScript ESM
vitest's include glob is .ts-only (tests/container/specs/**/*.ts), so the two .js files in tests/container were silently never collected, and the docker workflow's `pnpm run test-container` step exited 1 with: No test files found, exiting with code 1 Both files were small and pure CJS (require() + exports). Converted to ESM with vitest imports and import.meta.url-derived __dirname. Original .js files removed. Note: loadSettings reads ../../../settings.json.docker (three segments up to repo root) — preserved the original path.
This commit is contained in:
parent
b9928f3825
commit
7e9f3e2ffb
2 changed files with 12 additions and 7 deletions
|
|
@ -12,10 +12,15 @@
|
|||
* back to a default)
|
||||
*/
|
||||
|
||||
const fs = require('fs');
|
||||
const jsonminify = require('jsonminify');
|
||||
import fs from 'fs';
|
||||
import jsonminify from 'jsonminify';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { dirname } from 'node:path';
|
||||
|
||||
function loadSettings() {
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
|
||||
export function loadSettings(): any {
|
||||
let settingsStr = fs.readFileSync(`${__dirname}/../../../settings.json.docker`).toString();
|
||||
// try to parse the settings
|
||||
try {
|
||||
|
|
@ -33,5 +38,3 @@ function loadSettings() {
|
|||
console.error('whoops something is bad with settings');
|
||||
}
|
||||
}
|
||||
|
||||
exports.loadSettings = loadSettings;
|
||||
|
|
@ -5,9 +5,11 @@
|
|||
* TODO: unify those two files, and merge in a single one.
|
||||
*/
|
||||
|
||||
const settings = require('../../loadSettings').loadSettings();
|
||||
const supertest = require('supertest');
|
||||
import { describe, it } from 'vitest';
|
||||
import supertest from 'supertest';
|
||||
import { loadSettings } from '../../loadSettings.js';
|
||||
|
||||
const settings = loadSettings();
|
||||
const api = supertest(`http://${settings.ip}:${settings.port}`);
|
||||
const apiVersion = 1;
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue