Skip to content

Commit 5d84ef9

Browse files
committed
chore: convert v8-snapshot-require tests to vitest
1 parent a2d2f46 commit 5d84ef9

File tree

7 files changed

+36
-35
lines changed

7 files changed

+36
-35
lines changed

.circleci/src/pipeline/@pipeline.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1786,7 +1786,7 @@ jobs:
17861786
source ./scripts/ensure-node.sh
17871787
yarn lerna run types
17881788
- sanitize-verify-and-store-mocha-results:
1789-
expectedResultCount: 10
1789+
expectedResultCount: 9
17901790

17911791
verify-release-readiness:
17921792
<<: *defaults

guides/esm-migration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ When migrating some of these projects away from the `ts-node` entry [see `@packa
111111
- [x] packages/telemetry ✅ **COMPLETED**
112112
- [ ] packages/ts - ultimate goal is removal and likely not worth the effort to convert
113113
- [x] packages/types ✅ **COMPLETED**
114-
- [ ] packages/v8-snapshot-require
114+
- [x] packages/v8-snapshot-require**COMPLETED**
115115

116116
### Phase 3: Bundle ESM/CJS versions of NPM packages
117117

packages/v8-snapshot-require/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"clean": "rimraf dist",
1111
"clean-deps": "rimraf node_modules",
1212
"test": "yarn test-unit",
13-
"test-unit": "mocha --config ./test/.mocharc.js",
13+
"test-debug": "vitest --inspect-brk --no-file-parallelism --test-timeout=0",
14+
"test-unit": "vitest run",
1415
"tslint": "tslint --config ../ts/tslint.json --project .",
1516
"watch": "tsc --watch"
1617
},
@@ -21,7 +22,7 @@
2122
},
2223
"devDependencies": {
2324
"@tooling/packherd": "0.0.0-development",
24-
"mocha": "7.0.1"
25+
"vitest": "^3.2.4"
2526
},
2627
"files": [
2728
"dist",

packages/v8-snapshot-require/test/.mocharc.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

packages/v8-snapshot-require/test/dependency-map.circular.spec.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import { describe, it, expect } from 'vitest'
12
import { buildDependencyMap } from '@tooling/v8-snapshot'
23
import { DependencyMap } from '../src/dependency-map'
34
import type { Metadata } from '../src/types'
4-
import { expect } from 'chai'
55

66
const ROOT = 'lib/root.js'
77
const FOO = 'lib/foo.js'
@@ -84,18 +84,18 @@ const dp = new DependencyMap(map)
8484

8585
describe('dependency map: circular', () => {
8686
it('creates a map with circular dep - all deps ', () => {
87-
expect(dp.allDepsOf(ROOT)).to.deep.equal(ALL_ROOT)
88-
expect(dp.allDepsOf(FOO)).to.deep.equal(ALL_FOO)
89-
expect(dp.allDepsOf(BAR)).to.deep.equal(ALL_BAR)
90-
expect(dp.allDepsOf(BAZ)).to.deep.equal(ALL_BAZ)
91-
expect(dp.allDepsOf(FOZ)).to.deep.equal(ALL_FOZ)
87+
expect(dp.allDepsOf(ROOT)).toEqual(ALL_ROOT)
88+
expect(dp.allDepsOf(FOO)).toEqual(ALL_FOO)
89+
expect(dp.allDepsOf(BAR)).toEqual(ALL_BAR)
90+
expect(dp.allDepsOf(BAZ)).toEqual(ALL_BAZ)
91+
expect(dp.allDepsOf(FOZ)).toEqual(ALL_FOZ)
9292
})
9393

9494
it('creates a map with circular dep - direct deps ', () => {
95-
expect(dp.directDepsOf(ROOT)).to.deep.equal(DIRECT_ROOT)
96-
expect(dp.directDepsOf(FOO)).to.deep.equal(DIRECT_FOO)
97-
expect(dp.directDepsOf(BAR)).to.deep.equal(DIRECT_BAR)
98-
expect(dp.directDepsOf(BAZ)).to.deep.equal(DIRECT_BAZ)
99-
expect(dp.directDepsOf(FOZ)).to.deep.equal(DIRECT_FOZ)
95+
expect(dp.directDepsOf(ROOT)).toEqual(DIRECT_ROOT)
96+
expect(dp.directDepsOf(FOO)).toEqual(DIRECT_FOO)
97+
expect(dp.directDepsOf(BAR)).toEqual(DIRECT_BAR)
98+
expect(dp.directDepsOf(BAZ)).toEqual(DIRECT_BAZ)
99+
expect(dp.directDepsOf(FOZ)).toEqual(DIRECT_FOZ)
100100
})
101101
})

packages/v8-snapshot-require/test/dependency-map.spec.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import { describe, it, expect } from 'vitest'
12
import { buildDependencyMap } from '@tooling/v8-snapshot'
23
import { DependencyMap } from '../src/dependency-map'
34
import type { Metadata } from '../src/types'
4-
import { expect } from 'chai'
55

66
const NO_DEPS = 'lib/fixtures/no-deps.js'
77
const SYNC_DEPS = 'lib/fixtures/sync-deps.js'
@@ -68,31 +68,31 @@ describe('dependency map', () => {
6868
const cache: Record<string, NodeModule> = {}
6969

7070
for (const id of allIds) {
71-
expect(dp.loadedButNotCached(id, loaded, cache), `${id} not 'loaded but not cached'`).to.be.false
71+
expect(dp.loadedButNotCached(id, loaded, cache), `${id} not 'loaded but not cached'`).toBe(false)
7272
}
7373

7474
for (const id of allIds) {
7575
cache[id] = {} as NodeModule
7676
loaded.add(id)
7777
}
7878
for (const id of allIds) {
79-
expect(dp.loadedButNotCached(id, loaded, cache), `${id} not 'loaded but not cached'`).to.be.false
79+
expect(dp.loadedButNotCached(id, loaded, cache), `${id} not 'loaded but not cached'`).toBe(false)
8080
}
8181

8282
delete cache[NO_DEPS]
8383

8484
for (const id of allIds) {
8585
const res = id === NO_DEPS
8686

87-
expect(dp.loadedButNotCached(id, loaded, cache)).to.equal(res, `${id} ${res ? '' : 'not '} 'loaded but not cached'`)
87+
expect(dp.loadedButNotCached(id, loaded, cache)).toEqual(res, `${id} ${res ? '' : 'not '} 'loaded but not cached'`)
8888
}
8989

9090
delete cache[SYNC_DEPS]
9191

9292
for (const id of allIds) {
9393
const res = id === NO_DEPS || id === SYNC_DEPS
9494

95-
expect(dp.loadedButNotCached(id, loaded, cache)).to.equal(res, `${id} ${res ? '' : 'not '} 'loaded but not cached'`)
95+
expect(dp.loadedButNotCached(id, loaded, cache)).toEqual(res, `${id} ${res ? '' : 'not '} 'loaded but not cached'`)
9696
}
9797
})
9898

@@ -107,20 +107,20 @@ describe('dependency map', () => {
107107

108108
load(NO_DEPS)
109109

110-
expect(dp.criticalDependencyLoadedButNotCached(SYNC_DEPS, loaded, cache), 'SYNC_DEPS needs no reload').to.be.false
110+
expect(dp.criticalDependencyLoadedButNotCached(SYNC_DEPS, loaded, cache), 'SYNC_DEPS needs no reload').toBe(false)
111111

112112
delete cache[NO_DEPS]
113113

114-
expect(dp.criticalDependencyLoadedButNotCached(SYNC_DEPS, loaded, cache), 'SYNC_DEPS needs reload since not in cache and NO_DEPS is direct dep').to.be.true
114+
expect(dp.criticalDependencyLoadedButNotCached(SYNC_DEPS, loaded, cache), 'SYNC_DEPS needs reload since not in cache and NO_DEPS is direct dep').toBe(true)
115115

116-
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
116+
expect(dp.criticalDependencyLoadedButNotCached(DEEP_SYNC_DEPS, loaded, cache), 'DEEP_SYNC_DEPS needs reload since a cache free path to NO_DEPS exists').toBe(true)
117117

118-
expect(dp.criticalDependencyLoadedButNotCached(KEEP_JS, loaded, cache), 'KEEP_JS needs reload since a cache free path to NO_DEPS exists').to.be.true
118+
expect(dp.criticalDependencyLoadedButNotCached(KEEP_JS, loaded, cache), 'KEEP_JS needs reload since a cache free path to NO_DEPS exists').toBe(true)
119119

120120
load(SYNC_DEPS)
121121

122-
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
122+
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)
123123

124-
expect(dp.criticalDependencyLoadedButNotCached(KEEP_JS, loaded, cache), 'KEEP_JS needs no reload since no cache free path to NO_DEPS exists').to.be.false
124+
expect(dp.criticalDependencyLoadedButNotCached(KEEP_JS, loaded, cache), 'KEEP_JS needs no reload since no cache free path to NO_DEPS exists').toBe(false)
125125
})
126126
})
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { defineConfig } from 'vitest/config'
2+
3+
export default defineConfig({
4+
test: {
5+
include: ['test/**/*.spec.ts'],
6+
globals: true,
7+
environment: 'node',
8+
},
9+
})

0 commit comments

Comments
 (0)