diff --git a/packages/test-runner-junit-reporter/package.json b/packages/test-runner-junit-reporter/package.json index 266337955e..1e59d64b24 100644 --- a/packages/test-runner-junit-reporter/package.json +++ b/packages/test-runner-junit-reporter/package.json @@ -26,8 +26,8 @@ }, "scripts": { "build": "tsc", - "test": "mocha test/**/*.test.ts --require ts-node/register --reporter dot", - "test:watch": "mocha test/**/*.test.ts --require ts-node/register --watch --watch-files src,test --reporter dot" + "test:node": "node --experimental-strip-types --test --test-force-exit test/**/*.test.ts", + "test:watch": "node --experimental-strip-types --test --test-force-exit --watch test/**/*.test.ts" }, "files": [ "*.d.ts", diff --git a/packages/test-runner-junit-reporter/test/fixtures/multiple/expected.xml b/packages/test-runner-junit-reporter/test/fixtures/multiple/expected.xml index 13af3840be..560e5fc9df 100644 --- a/packages/test-runner-junit-reporter/test/fixtures/multiple/expected.xml +++ b/packages/test-runner-junit-reporter/test/fixtures/multiple/expected.xml @@ -1,28 +1,28 @@ - + - + - + - + - + - - - + + + > (packages/test-runner-junit-reporter/test/fixtures/multiple/simple-test.js:15:29)]]> + at <> (test/fixtures/multiple/simple-test.js:15:29)]]> - + - + \ No newline at end of file diff --git a/packages/test-runner-junit-reporter/test/fixtures/nested/expected.xml b/packages/test-runner-junit-reporter/test/fixtures/nested/expected.xml index d1383961ef..fe103402e3 100644 --- a/packages/test-runner-junit-reporter/test/fixtures/nested/expected.xml +++ b/packages/test-runner-junit-reporter/test/fixtures/nested/expected.xml @@ -1,11 +1,11 @@ - + - + - + \ No newline at end of file diff --git a/packages/test-runner-junit-reporter/test/fixtures/simple/expected.xml b/packages/test-runner-junit-reporter/test/fixtures/simple/expected.xml index 93eb434893..4386a40677 100644 --- a/packages/test-runner-junit-reporter/test/fixtures/simple/expected.xml +++ b/packages/test-runner-junit-reporter/test/fixtures/simple/expected.xml @@ -1,25 +1,25 @@ - + - + - - - + + + > (packages/test-runner-junit-reporter/test/fixtures/simple/simple-test.js:17:29)]]> + at <> (test/fixtures/simple/simple-test.js:17:29)]]> - + - - + + > (packages/test-runner-junit-reporter/test/fixtures/simple/simple-test.js:33:17)]]> + at fail (test/fixtures/simple/simple-source.js:2:9) + at <> (test/fixtures/simple/simple-test.js:33:17)]]> \ No newline at end of file diff --git a/packages/test-runner-junit-reporter/test/junitReporter.test.ts b/packages/test-runner-junit-reporter/test/junitReporter.test.ts index 79e63fed3e..7c04c05f4f 100644 --- a/packages/test-runner-junit-reporter/test/junitReporter.test.ts +++ b/packages/test-runner-junit-reporter/test/junitReporter.test.ts @@ -1,18 +1,19 @@ -import { expect } from 'chai'; +import { describe, it, after } from 'node:test'; +import assert from 'node:assert/strict'; import { promises as fs } from 'fs'; import path from 'path'; import globby from 'globby'; import { chromeLauncher } from '@web/test-runner-chrome'; -import { TestRunnerCoreConfig } from '@web/test-runner-core'; +import type { TestRunnerCoreConfig } from '@web/test-runner-core'; import { runTests } from '@web/test-runner-core/test-helpers'; -import { junitReporter } from '../src/junitReporter.js'; +import { junitReporter } from '../dist/junitReporter.js'; const NON_ZERO_TIME_VALUE_REGEX = /time="((\d\.\d+)|(\d))"/g; const USER_AGENT_STRING_REGEX = /"Mozilla\/5\.0 (.*)"/g; -const rootDir = path.join(__dirname, '..', '..', '..'); +const rootDir = path.resolve(import.meta.dirname, '..', '..', '..'); const normalizeOutput = (cwd: string, output: string) => output @@ -64,35 +65,35 @@ async function run(cwd: string): Promise<{ actual: string; expected: string }> { async function cleanupFixtures() { for (const file of await globby('fixtures/**/test-results.xml', { absolute: true, - cwd: __dirname, + cwd: import.meta.dirname, })) await fs.unlink(file); } -describe('junitReporter', function () { +describe('junitReporter', () => { after(cleanupFixtures); - describe('for a simple case', function () { - const fixtureDir = path.join(__dirname, 'fixtures/simple'); - it('produces expected results', async function () { + describe('for a simple case', () => { + const fixtureDir = path.join(import.meta.dirname, 'fixtures/simple'); + it('produces expected results', async () => { const { actual, expected } = await run(fixtureDir); - expect(actual).to.equal(expected); + assert.equal(actual, expected); }); }); - describe('for a nested suite', function () { - const fixtureDir = path.join(__dirname, 'fixtures/nested'); - it('produces expected results', async function () { + describe('for a nested suite', () => { + const fixtureDir = path.join(import.meta.dirname, 'fixtures/nested'); + it('produces expected results', async () => { const { actual, expected } = await run(fixtureDir); - expect(actual).to.equal(expected); + assert.equal(actual, expected); }); }); - describe('for multiple test files', function () { - const fixtureDir = path.join(__dirname, 'fixtures/multiple'); - it('produces expected results', async function () { + describe('for multiple test files', () => { + const fixtureDir = path.join(import.meta.dirname, 'fixtures/multiple'); + it('produces expected results', async () => { const { actual, expected } = await run(fixtureDir); - expect(actual).to.equal(expected); + assert.equal(actual, expected); }); }); });