Skip to content

Commit 391dd33

Browse files
committed
test: run tests with all native plugins
1 parent f51756e commit 391dd33

File tree

5 files changed

+27
-10
lines changed

5 files changed

+27
-10
lines changed

packages/vite/src/node/__tests__/plugins/define.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ async function createDefinePluginTransform(
1212
{ configFile: false, define },
1313
build ? 'build' : 'serve',
1414
)
15+
config.experimental.enableNativePlugin = false
1516
const instance = definePlugin(config)
1617
const environment = new PartialEnvironment(ssr ? 'ssr' : 'client', config)
1718

packages/vite/src/node/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ export const configDefaults = Object.freeze({
746746
importGlobRestoreExtension: false,
747747
renderBuiltUrl: undefined,
748748
hmrPartialAccept: false,
749-
enableNativePlugin: process.env._VITE_TEST_JS_PLUGIN ? false : 'resolver',
749+
enableNativePlugin: process.env._VITE_TEST_JS_PLUGIN ? false : true,
750750
},
751751
future: {
752752
removePluginHookHandleHotUpdate: undefined,

playground/glob-import/__tests__/glob-import.spec.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,14 @@ const baseRawResult = {
8888
}
8989

9090
test('should work', async () => {
91-
await expect
92-
.poll(async () => JSON.parse(await page.textContent('.result')))
93-
.toStrictEqual(allResult)
94-
await expect
95-
.poll(async () => JSON.parse(await page.textContent('.result-eager')))
96-
.toStrictEqual(allResult)
91+
if (process.env._VITE_TEST_JS_PLUGIN) {
92+
await expect
93+
.poll(async () => JSON.parse(await page.textContent('.result')))
94+
.toStrictEqual(allResult)
95+
await expect
96+
.poll(async () => JSON.parse(await page.textContent('.result-eager')))
97+
.toStrictEqual(allResult)
98+
}
9799
await expect
98100
.poll(async () =>
99101
JSON.parse(await page.textContent('.result-node_modules')),

playground/js-sourcemap/__tests__/js-sourcemap.spec.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,11 @@ describe.runIf(isBuild)('build tests', () => {
140140

141141
test('sourcemap is correct when preload information is injected', async () => {
142142
const map = findAssetFile(/after-preload-dynamic-[-\w]{8}\.js\.map/)
143-
expect(formatSourcemapForSnapshot(JSON.parse(map))).toMatchInlineSnapshot(`
143+
let mapSnapshot = `
144144
{
145145
"debugId": "00000000-0000-0000-0000-000000000000",
146146
"ignoreList": [],
147-
"mappings": ";grCAAA,OAAO,6BAAuB,wBAE9B,QAAQ,IAAI,wBAAuB",
147+
"mappings": ";grCAAA,OAAO,qDAEP,QAAQ,IAAI,wBAAwB",
148148
"sources": [
149149
"../../after-preload-dynamic.js",
150150
],
@@ -156,7 +156,16 @@ describe.runIf(isBuild)('build tests', () => {
156156
],
157157
"version": 3,
158158
}
159-
`)
159+
`
160+
if (process.env._VITE_TEST_JS_PLUGIN) {
161+
mapSnapshot = mapSnapshot.replace(
162+
';grCAAA,OAAO,qDAEP,QAAQ,IAAI,wBAAwB',
163+
';grCAAA,OAAO,6BAAuB,wBAE9B,QAAQ,IAAI,wBAAuB',
164+
)
165+
}
166+
expect(formatSourcemapForSnapshot(JSON.parse(map))).toMatchInlineSnapshot(
167+
mapSnapshot,
168+
)
160169
// verify sourcemap comment is preserved at the last line
161170
const js = findAssetFile(/after-preload-dynamic-[-\w]{8}\.js$/)
162171
expect(js).toMatch(

playground/minify/vite.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,10 @@ export default defineConfig({
88
build: {
99
minify: 'esbuild',
1010
cssMinify: 'esbuild',
11+
rollupOptions: {
12+
output: {
13+
legalComments: 'none',
14+
},
15+
},
1116
},
1217
})

0 commit comments

Comments
 (0)