diff --git a/.circleci/src/pipeline/@pipeline.yml b/.circleci/src/pipeline/@pipeline.yml index 5420f375817..d9a11bc809c 100644 --- a/.circleci/src/pipeline/@pipeline.yml +++ b/.circleci/src/pipeline/@pipeline.yml @@ -1786,7 +1786,7 @@ jobs: source ./scripts/ensure-node.sh yarn lerna run types - sanitize-verify-and-store-mocha-results: - expectedResultCount: 10 + expectedResultCount: 9 verify-release-readiness: <<: *defaults diff --git a/guides/esm-migration.md b/guides/esm-migration.md index f9b2cd4905a..bdbc9120c63 100644 --- a/guides/esm-migration.md +++ b/guides/esm-migration.md @@ -111,7 +111,7 @@ When migrating some of these projects away from the `ts-node` entry [see `@packa - [x] packages/telemetry ✅ **COMPLETED** - [ ] packages/ts - ultimate goal is removal and likely not worth the effort to convert - [x] packages/types ✅ **COMPLETED** -- [ ] packages/v8-snapshot-require +- [x] packages/v8-snapshot-require ✅ **COMPLETED** ### Phase 3: Bundle ESM/CJS versions of NPM packages diff --git a/packages/v8-snapshot-require/package.json b/packages/v8-snapshot-require/package.json index 4bffe2c34bb..6ea8708fc93 100644 --- a/packages/v8-snapshot-require/package.json +++ b/packages/v8-snapshot-require/package.json @@ -10,7 +10,8 @@ "clean": "rimraf dist", "clean-deps": "rimraf node_modules", "test": "yarn test-unit", - "test-unit": "mocha --config ./test/.mocharc.js", + "test-debug": "vitest --inspect-brk --no-file-parallelism --test-timeout=0", + "test-unit": "vitest run", "tslint": "tslint --config ../ts/tslint.json --project .", "watch": "tsc --watch" }, @@ -21,7 +22,7 @@ }, "devDependencies": { "@tooling/packherd": "0.0.0-development", - "mocha": "7.0.1" + "vitest": "^3.2.4" }, "files": [ "dist", diff --git a/packages/v8-snapshot-require/test/.mocharc.js b/packages/v8-snapshot-require/test/.mocharc.js deleted file mode 100644 index 9720d8a75cb..00000000000 --- a/packages/v8-snapshot-require/test/.mocharc.js +++ /dev/null @@ -1,9 +0,0 @@ -module.exports = { - require: '@packages/ts/register', - reporter: 'mocha-multi-reporters', - reporterOptions: { - configFile: '../../mocha-reporter-config.json', - }, - spec: 'test/**/*.spec.ts', - watchFiles: ['test/**/*.ts', 'src/**/*.ts'], -} diff --git a/packages/v8-snapshot-require/test/dependency-map.circular.spec.ts b/packages/v8-snapshot-require/test/dependency-map.circular.spec.ts index adf467349ec..d74cf5a0c3a 100644 --- a/packages/v8-snapshot-require/test/dependency-map.circular.spec.ts +++ b/packages/v8-snapshot-require/test/dependency-map.circular.spec.ts @@ -1,7 +1,7 @@ +import { describe, it, expect } from 'vitest' import { buildDependencyMap } from '@tooling/v8-snapshot' import { DependencyMap } from '../src/dependency-map' import type { Metadata } from '../src/types' -import { expect } from 'chai' const ROOT = 'lib/root.js' const FOO = 'lib/foo.js' @@ -84,18 +84,18 @@ const dp = new DependencyMap(map) describe('dependency map: circular', () => { it('creates a map with circular dep - all deps ', () => { - expect(dp.allDepsOf(ROOT)).to.deep.equal(ALL_ROOT) - expect(dp.allDepsOf(FOO)).to.deep.equal(ALL_FOO) - expect(dp.allDepsOf(BAR)).to.deep.equal(ALL_BAR) - expect(dp.allDepsOf(BAZ)).to.deep.equal(ALL_BAZ) - expect(dp.allDepsOf(FOZ)).to.deep.equal(ALL_FOZ) + expect(dp.allDepsOf(ROOT)).toEqual(ALL_ROOT) + expect(dp.allDepsOf(FOO)).toEqual(ALL_FOO) + expect(dp.allDepsOf(BAR)).toEqual(ALL_BAR) + expect(dp.allDepsOf(BAZ)).toEqual(ALL_BAZ) + expect(dp.allDepsOf(FOZ)).toEqual(ALL_FOZ) }) it('creates a map with circular dep - direct deps ', () => { - expect(dp.directDepsOf(ROOT)).to.deep.equal(DIRECT_ROOT) - expect(dp.directDepsOf(FOO)).to.deep.equal(DIRECT_FOO) - expect(dp.directDepsOf(BAR)).to.deep.equal(DIRECT_BAR) - expect(dp.directDepsOf(BAZ)).to.deep.equal(DIRECT_BAZ) - expect(dp.directDepsOf(FOZ)).to.deep.equal(DIRECT_FOZ) + expect(dp.directDepsOf(ROOT)).toEqual(DIRECT_ROOT) + expect(dp.directDepsOf(FOO)).toEqual(DIRECT_FOO) + expect(dp.directDepsOf(BAR)).toEqual(DIRECT_BAR) + expect(dp.directDepsOf(BAZ)).toEqual(DIRECT_BAZ) + expect(dp.directDepsOf(FOZ)).toEqual(DIRECT_FOZ) }) }) diff --git a/packages/v8-snapshot-require/test/dependency-map.spec.ts b/packages/v8-snapshot-require/test/dependency-map.spec.ts index cfdebbee801..85ff067ca03 100644 --- a/packages/v8-snapshot-require/test/dependency-map.spec.ts +++ b/packages/v8-snapshot-require/test/dependency-map.spec.ts @@ -1,7 +1,7 @@ +import { describe, it, expect } from 'vitest' import { buildDependencyMap } from '@tooling/v8-snapshot' import { DependencyMap } from '../src/dependency-map' import type { Metadata } from '../src/types' -import { expect } from 'chai' const NO_DEPS = 'lib/fixtures/no-deps.js' const SYNC_DEPS = 'lib/fixtures/sync-deps.js' @@ -68,7 +68,7 @@ describe('dependency map', () => { const cache: Record = {} for (const id of allIds) { - expect(dp.loadedButNotCached(id, loaded, cache), `${id} not 'loaded but not cached'`).to.be.false + expect(dp.loadedButNotCached(id, loaded, cache), `${id} not 'loaded but not cached'`).toBe(false) } for (const id of allIds) { @@ -76,7 +76,7 @@ describe('dependency map', () => { loaded.add(id) } for (const id of allIds) { - expect(dp.loadedButNotCached(id, loaded, cache), `${id} not 'loaded but not cached'`).to.be.false + expect(dp.loadedButNotCached(id, loaded, cache), `${id} not 'loaded but not cached'`).toBe(false) } delete cache[NO_DEPS] @@ -84,7 +84,7 @@ describe('dependency map', () => { for (const id of allIds) { const res = id === NO_DEPS - expect(dp.loadedButNotCached(id, loaded, cache)).to.equal(res, `${id} ${res ? '' : 'not '} 'loaded but not cached'`) + expect(dp.loadedButNotCached(id, loaded, cache)).toEqual(res, `${id} ${res ? '' : 'not '} 'loaded but not cached'`) } delete cache[SYNC_DEPS] @@ -92,7 +92,7 @@ describe('dependency map', () => { for (const id of allIds) { const res = id === NO_DEPS || id === SYNC_DEPS - expect(dp.loadedButNotCached(id, loaded, cache)).to.equal(res, `${id} ${res ? '' : 'not '} 'loaded but not cached'`) + expect(dp.loadedButNotCached(id, loaded, cache)).toEqual(res, `${id} ${res ? '' : 'not '} 'loaded but not cached'`) } }) @@ -107,20 +107,20 @@ describe('dependency map', () => { load(NO_DEPS) - expect(dp.criticalDependencyLoadedButNotCached(SYNC_DEPS, loaded, cache), 'SYNC_DEPS needs no reload').to.be.false + expect(dp.criticalDependencyLoadedButNotCached(SYNC_DEPS, loaded, cache), 'SYNC_DEPS needs no reload').toBe(false) delete cache[NO_DEPS] - expect(dp.criticalDependencyLoadedButNotCached(SYNC_DEPS, loaded, cache), 'SYNC_DEPS needs reload since not in cache and NO_DEPS is direct dep').to.be.true + expect(dp.criticalDependencyLoadedButNotCached(SYNC_DEPS, loaded, cache), 'SYNC_DEPS needs reload since not in cache and NO_DEPS is direct dep').toBe(true) - expect(dp.criticalDependencyLoadedButNotCached(DEEP_SYNC_DEPS, loaded, cache), 'DEEP_SYNC_DEPS needs reload since a cache free path to NO_DEPS exists').to.be.true + expect(dp.criticalDependencyLoadedButNotCached(DEEP_SYNC_DEPS, loaded, cache), 'DEEP_SYNC_DEPS needs reload since a cache free path to NO_DEPS exists').toBe(true) - expect(dp.criticalDependencyLoadedButNotCached(KEEP_JS, loaded, cache), 'KEEP_JS needs reload since a cache free path to NO_DEPS exists').to.be.true + expect(dp.criticalDependencyLoadedButNotCached(KEEP_JS, loaded, cache), 'KEEP_JS needs reload since a cache free path to NO_DEPS exists').toBe(true) load(SYNC_DEPS) - expect(dp.criticalDependencyLoadedButNotCached(DEEP_SYNC_DEPS, loaded, cache), 'DEEP_SYNC_DEPS needs no reload since no cache free path to NO_DEPS exists').to.be.false + expect(dp.criticalDependencyLoadedButNotCached(DEEP_SYNC_DEPS, loaded, cache), 'DEEP_SYNC_DEPS needs no reload since no cache free path to NO_DEPS exists').toBe(false) - expect(dp.criticalDependencyLoadedButNotCached(KEEP_JS, loaded, cache), 'KEEP_JS needs no reload since no cache free path to NO_DEPS exists').to.be.false + expect(dp.criticalDependencyLoadedButNotCached(KEEP_JS, loaded, cache), 'KEEP_JS needs no reload since no cache free path to NO_DEPS exists').toBe(false) }) }) diff --git a/packages/v8-snapshot-require/vitest.config.ts b/packages/v8-snapshot-require/vitest.config.ts new file mode 100644 index 00000000000..1a9a321880f --- /dev/null +++ b/packages/v8-snapshot-require/vitest.config.ts @@ -0,0 +1,9 @@ +import { defineConfig } from 'vitest/config' + +export default defineConfig({ + test: { + include: ['test/**/*.spec.ts'], + globals: true, + environment: 'node', + }, +})