diff --git a/packages/dev-server-import-maps/package.json b/packages/dev-server-import-maps/package.json index f76f368abd..74e7e0aae4 100644 --- a/packages/dev-server-import-maps/package.json +++ b/packages/dev-server-import-maps/package.json @@ -26,9 +26,9 @@ }, "scripts": { "build": "tsc", - "test": "mocha \"test/**/*.test.ts\" --require ts-node/register", "test:browser": "node ../test-runner/dist/bin.js test-browser/test/**/*.test.{js,html} --config test-browser/web-test-runner.config.mjs", - "test:watch": "mocha \"test/**/*.test.ts\" --require ts-node/register --watch --watch-files src,test" + "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/dev-server-import-maps/test/injection.test.ts b/packages/dev-server-import-maps/test/injection.test.ts index b55c2a42b1..686c6c69bf 100644 --- a/packages/dev-server-import-maps/test/injection.test.ts +++ b/packages/dev-server-import-maps/test/injection.test.ts @@ -1,11 +1,12 @@ +import { it } from 'node:test'; import { createTestServer, expectNotIncludes } from '@web/dev-server-core/test-helpers'; import { fetchText, expectIncludes, virtualFilesPlugin } from '@web/dev-server-core/test-helpers'; -import { importMapsPlugin } from '../src/importMapsPlugin.js'; +import { importMapsPlugin } from '../dist/importMapsPlugin.js'; it('can inject an import map into any page', async () => { const { server, host } = await createTestServer({ - rootDir: __dirname, + rootDir: import.meta.dirname, plugins: [ virtualFilesPlugin({ '/index.html': '
', @@ -28,7 +29,7 @@ it('can inject an import map into any page', async () => { it('can use an include pattern', async () => { const { server, host } = await createTestServer({ - rootDir: __dirname, + rootDir: import.meta.dirname, plugins: [ virtualFilesPlugin({ '/foo/a.html': '', @@ -58,7 +59,7 @@ it('can use an include pattern', async () => { it('can use an exclude pattern', async () => { const { server, host } = await createTestServer({ - rootDir: __dirname, + rootDir: import.meta.dirname, plugins: [ virtualFilesPlugin({ '/foo/a.html': '', @@ -86,7 +87,7 @@ it('can use an exclude pattern', async () => { it('treats directory paths with an implicit index.html file', async () => { const { server, host } = await createTestServer({ - rootDir: __dirname, + rootDir: import.meta.dirname, plugins: [ { name: 'test', @@ -116,7 +117,7 @@ it('treats directory paths with an implicit index.html file', async () => { it('merges with an existing import map', async () => { const { server, host } = await createTestServer({ - rootDir: __dirname, + rootDir: import.meta.dirname, plugins: [ virtualFilesPlugin({ '/index.html': @@ -146,7 +147,7 @@ it('merges with an existing import map', async () => { it('merges import map scopes', async () => { const { server, host } = await createTestServer({ - rootDir: __dirname, + rootDir: import.meta.dirname, plugins: [ virtualFilesPlugin({ '/index.html': @@ -176,7 +177,7 @@ it('merges import map scopes', async () => { it('the import map in the HTML file takes priority over the injected import map', async () => { const { server, host } = await createTestServer({ - rootDir: __dirname, + rootDir: import.meta.dirname, plugins: [ virtualFilesPlugin({ '/index.html': diff --git a/packages/dev-server-import-maps/test/resolving.test.ts b/packages/dev-server-import-maps/test/resolving.test.ts index bc3368a78a..b4571b5ea1 100644 --- a/packages/dev-server-import-maps/test/resolving.test.ts +++ b/packages/dev-server-import-maps/test/resolving.test.ts @@ -1,11 +1,11 @@ +import { describe, it, mock } from 'node:test'; +import assert from 'node:assert/strict'; import { fetchText, expectIncludes, virtualFilesPlugin } from '@web/dev-server-core/test-helpers'; import { createTestServer } from '@web/dev-server-core/test-helpers'; -import { expect } from 'chai'; -import { spy } from 'hanbi'; import path from 'path'; -import { importMapsPlugin } from '../src/importMapsPlugin.js'; -import { IMPORT_MAP_PARAM } from '../src/utils.js'; +import { importMapsPlugin } from '../dist/importMapsPlugin.js'; +import { IMPORT_MAP_PARAM } from '../dist/utils.js'; function createHtml(importMap: Record