-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: enable Rspack config schema validation by default (#3295)
- Loading branch information
1 parent
5e84bdc
commit bf0f684
Showing
4 changed files
with
57 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,67 @@ | ||
import { build, rspackOnlyTest } from '@e2e/helper'; | ||
import { build, proxyConsole, rspackOnlyTest } from '@e2e/helper'; | ||
import { expect } from '@playwright/test'; | ||
|
||
rspackOnlyTest('should allow to override rspack config validate', async () => { | ||
const { RSPACK_CONFIG_VALIDATE } = process.env; | ||
process.env.RSPACK_CONFIG_VALIDATE = 'strict'; | ||
|
||
rspackOnlyTest('should validate rspack config by default', async () => { | ||
try { | ||
await build({ | ||
cwd: __dirname, | ||
rsbuildConfig: { | ||
tools: { | ||
// @ts-expect-error mock invalid config | ||
rspack: { | ||
entry: 1, | ||
}, | ||
}, | ||
}, | ||
}); | ||
} catch (e) { | ||
expect(e).toBeTruthy(); | ||
expect((e as Error).message).toContain('Expected object, received number'); | ||
} | ||
}); | ||
|
||
rspackOnlyTest('should warn when passing unrecognized keys', async () => { | ||
const { logs, restore } = proxyConsole(); | ||
await build({ | ||
cwd: __dirname, | ||
rsbuildConfig: { | ||
tools: { | ||
rspack: { | ||
// @ts-expect-error mock invalid config | ||
unrecognized: 1, | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
expect( | ||
logs.some((log) => | ||
log.includes(`Unrecognized key(s) in object: 'unrecognized'`), | ||
), | ||
); | ||
restore(); | ||
}); | ||
|
||
rspackOnlyTest('should allow to override rspack config validate', async () => { | ||
const { RSPACK_CONFIG_VALIDATE } = process.env; | ||
process.env.RSPACK_CONFIG_VALIDATE = 'loose'; | ||
|
||
const { logs, restore } = proxyConsole(); | ||
|
||
await build({ | ||
cwd: __dirname, | ||
rsbuildConfig: { | ||
tools: { | ||
// @ts-expect-error mock invalid config | ||
rspack: { | ||
entry: 1, | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
expect(logs.some((log) => log.includes('Expected object, received number'))); | ||
|
||
process.env.RSPACK_CONFIG_VALIDATE = RSPACK_CONFIG_VALIDATE; | ||
restore(); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -107,6 +107,7 @@ subpage | |
subresource | ||
subresources | ||
svgr | ||
sveltejs | ||
swcrc | ||
systemjs | ||
tailwindcss | ||
|