refactor(dev-server-legacy): migrate tests to node:test#3083
refactor(dev-server-legacy): migrate tests to node:test#3083bennypowers wants to merge 2 commits into
Conversation
Replace mocha globals and chai assertions with node:test and
node:assert/strict. First TypeScript test migration in the series.
- `import { expect } from 'chai'` -> `import assert from 'node:assert/strict'`
- Add `import { describe, it } from 'node:test'`
- `expect(x).to.equal(y)` -> `assert.equal(x, y)`
- `this.timeout(10000)` -> `{ timeout: 10000 }` option on describe
- `__dirname` -> `import.meta.dirname`
- `../src/legacyPlugin.js` -> `../dist/legacyPlugin.js`
- `./userAgents.js` -> `./userAgents.ts`
- Add `--test-force-exit` to prevent test hangs from open handles
Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
CI sets NODE_OPTIONS='--no-experimental-strip-types' to support un-migrated mocha+ts-node packages. The CLI flag overrides NODE_OPTIONS, letting migrated .ts test files run with native type stripping. Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
| import { legacyPlugin } from '../src/legacyPlugin.js'; | ||
| import { modernUserAgents, legacyUserAgents } from './userAgents.js'; | ||
| import { legacyPlugin } from '../dist/legacyPlugin.js'; | ||
| import { modernUserAgents, legacyUserAgents } from './userAgents.ts'; |
There was a problem hiding this comment.
@bennypowers I don't quite get now why we need to import from "dist" while we can import from ".ts"? your earlier reply #3097 (comment) now is not clear to me, I mean it's also a relative import, right? not sure what I am missing
Summary
@web/dev-server-legacytests from mocha/chai tonode:test+node:assert/strictdist/(compiled output)__dirnamereplaced withimport.meta.dirname.jsimport paths updated to.tsTest plan