-
Notifications
You must be signed in to change notification settings - Fork 392
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: migrate from jest to vitest #4396
Changes from all commits
bcf86b9
c678adf
df4fb25
ba32129
c547611
045acda
32ce3fa
9407101
a28c0a0
cf3b131
dddc404
4bcae68
ebc40ec
f6669f9
de4cb42
4909030
1c3d5fc
147904a
78e5639
321c1d5
eb7319a
b3df5b2
a5e2e6d
a804c83
00b229f
5d4aa0e
00236a6
2372384
d4b1aed
6b20fd8
0329a43
3f48a35
ee4f3ab
98b6d78
5a6e294
1f306bc
6550ff9
ce2beae
39def4e
74351ce
4fd44e7
3b2954e
7457eb1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { mergeConfig, defineProject } from 'vitest/config'; | ||
import sharedConfig from '../../../vitest.shared.mjs'; | ||
|
||
export default mergeConfig( | ||
sharedConfig, | ||
defineProject({ | ||
test: { | ||
name: 'babel-plugin-component', | ||
}, | ||
}) | ||
); |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { defineProject, mergeConfig } from 'vitest/config'; | ||
import baseConfig from '../../../vitest.shared.mjs'; | ||
|
||
export default mergeConfig( | ||
baseConfig, | ||
defineProject({ | ||
test: { | ||
name: 'lwc-compiler', | ||
}, | ||
}) | ||
); |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { defineProject, mergeConfig } from 'vitest/config'; | ||
import baseConfig from '../../../vitest.shared.mjs'; | ||
|
||
export default mergeConfig( | ||
baseConfig, | ||
defineProject({ | ||
test: { | ||
name: 'lwc-engine-core', | ||
}, | ||
}) | ||
); |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { defineProject, mergeConfig } from 'vitest/config'; | ||
import baseConfig from '../../../vitest.shared.mjs'; | ||
|
||
export default mergeConfig( | ||
baseConfig, | ||
defineProject({ | ||
test: { | ||
name: 'lwc-engine-dom', | ||
environment: 'jsdom', | ||
}, | ||
}) | ||
); |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,8 @@ import path from 'path'; | |
|
||
import { rollup } from 'rollup'; | ||
import lwcRollupPlugin from '@lwc/rollup-plugin'; | ||
import { testFixtureDir, formatHTML } from '@lwc/jest-utils-lwc-internals'; | ||
import { vi } from 'vitest'; | ||
import { testFixtureDir, formatHTML } from '@lwc/test-utils-lwc-internals'; | ||
import type * as lwc from '../index'; | ||
|
||
interface FixtureModule { | ||
|
@@ -20,7 +21,17 @@ interface FixtureModule { | |
features?: any[]; | ||
} | ||
|
||
jest.setTimeout(10_000 /* 10 seconds */); | ||
vi.setConfig({ testTimeout: 10_000 /* 10 seconds */ }); | ||
|
||
vi.mock('lwc', async () => { | ||
const lwcEngineServer = await import('../index'); | ||
lwcEngineServer!.setHooks({ | ||
sanitizeHtmlContent(content: unknown) { | ||
return content as string; | ||
}, | ||
}); | ||
return lwcEngineServer; | ||
}); | ||
|
||
async function compileFixture({ input, dirname }: { input: string; dirname: string }) { | ||
const modulesDir = path.resolve(dirname, './modules'); | ||
|
@@ -49,7 +60,7 @@ async function compileFixture({ input, dirname }: { input: string; dirname: stri | |
|
||
await bundle.write({ | ||
file: outputFile, | ||
format: 'cjs', | ||
format: 'esm', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Jest doesn't like ES Modules and Vitest doesn't like CJS... Hopefully this is fine. |
||
exports: 'named', | ||
}); | ||
|
||
|
@@ -80,24 +91,14 @@ function testFixtures() { | |
// On top of this, the engine also checks if the component constructor is an instance of | ||
// the LightningElement. Therefor the compiled module should also be evaluated in the | ||
// same sandbox registry as the engine. | ||
let lwcEngineServer: typeof lwc | undefined; | ||
let module: FixtureModule | undefined; | ||
jest.isolateModules(() => { | ||
lwcEngineServer = require('../index'); | ||
module = require(compiledFixturePath); | ||
}); | ||
const lwcEngineServer = await import('../index'); | ||
const module = (await import(compiledFixturePath)) as FixtureModule; | ||
|
||
const features = module!.features ?? []; | ||
features.forEach((flag) => { | ||
lwcEngineServer!.setFeatureFlagForTest(flag, true); | ||
}); | ||
|
||
lwcEngineServer!.setHooks({ | ||
sanitizeHtmlContent(content: unknown) { | ||
return content as string; | ||
}, | ||
}); | ||
|
||
let result; | ||
let err; | ||
try { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { defineProject, mergeConfig } from 'vitest/config'; | ||
import baseConfig from '../../../vitest.shared.mjs'; | ||
|
||
export default mergeConfig( | ||
baseConfig, | ||
defineProject({ | ||
test: { | ||
name: 'lwc-engine-server', | ||
}, | ||
}) | ||
); |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { mergeConfig, defineProject } from 'vitest/config'; | ||
import sharedConfig from '../../../vitest.shared.mjs'; | ||
|
||
export default mergeConfig( | ||
sharedConfig, | ||
defineProject({ | ||
test: { | ||
name: 'lwc-errors', | ||
}, | ||
}) | ||
); |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No longer needed, only needed for Jest