Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Integration of Ajv with test runner? #2280

Unanswered
redm123 asked this question in Q&A
Discussion options

Hi all! I would like to use the Ajv schema validator in my tests (or any other fwiw, but I found none that worked in the test runner..). However I can't seem to be able to import that module. I wonder if this is just me not having the right configuration, or if it is not working at all?

Either I'm getting:

🚧 Browser logs:
 SyntaxError: The requested module '/__wds-outside-root__/1/node_modules/ajv/lib/ajv.js' does not provide an export named 'Ajv'
 ❌ Could not import your test module. Check the browser logs or open the browser in debug mode for more information.

or

🚧 Browser logs:
 TypeError: Failed to fetch dynamically imported module: http://localhost:8000/src/foobar.test.js?wtr-session-id=ZDJ2XRyAKqxRgzmHhoBLB
 ❌ Could not import your test module. Check the browser logs or open the browser in debug mode for more information.

Which apparently already fails starting up the test runner. The suggested browser logs are not of much help...

I tried playing with test runner config and rollup plugins... I got something, to a certain extent, that something is converted. However, the actual module still can't be loaded.

Config wise I currently have something along the lines of:

const commonjs = fromRollup(rollupCommonjs);
const rupjson = fromRollup(rollupJson);
const resolve = fromRollup(rollupResolve);
...
export default /** @type {import("@web/test-runner").TestRunnerConfig} */ ({
...
 mimeTypes: {
 // serve all json files as js
 '**/*.json': 'js',
 },
 plugins: [
 rupjson({
 include: ['../../**/node_modules/ajv/**/*'],
 }),
 commonjs({
 include: ['../../**/node_modules/ajv/**/*'],
 }),
 //resolve(),
 ],
...
You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /