Skip to content
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

Error when executing test "Failed to fetch dynamically imported module" #2645

Open
PRK0001 opened this issue Feb 21, 2024 · 7 comments
Open

Comments

@PRK0001
Copy link

PRK0001 commented Feb 21, 2024

We are trying to replace karma by web-test-runner but I have the following errors when I am launching tests:

image

after running the browser in debug mode ,following errors had been displayed:
image

Versions:
"@esm-bundle/chai": "4.3.4",
"@web/test-runner": "^0.18.0",
"@web/test-runner-chrome": "^0.5.9",

Web test runner config:

import { esbuildPlugin } from '@web/dev-server-esbuild';
import { jasmineTestRunnerConfig } from 'web-test-runner-jasmine';
export default ({
...jasmineTestRunnerConfig(),

nodeResolve: true,
files: ['./test/*.spec.ts'],
browsers: ["Chrome_headless"],
customLaunchers: {
'Chrome_headless': {
base: 'Chrome',
flags: [
'--no-sandbox',
]
},
},
plugins: [esbuildPlugin({ ts: true, json: true, target: 'auto', sourceMap: true })]
});

Webpack config:

const path = require('path');
module.exports = {
mode: 'development',
entry: {
PowerBIEmbedTest: path.resolve('test/PowerBIEmbed.spec.tsx'),
utilsTest: path.resolve('test/utils.spec.ts'),
},
output: {
path: path.resolve('compiledTests'),
filename: '[name].spec.js'
},
devtool: 'source-map',
module: {
rules: [
{
test: /.ts(x)?$/,
loader: 'ts-loader',
options: {
configFile: path.resolve('config/test/tsconfig.json')
},
exclude: /node_modules/
},
]
},
resolve: {
extensions: [
'.tsx',
'.ts',
'.js'
]
},
};

@gethari
Copy link

gethari commented Mar 5, 2024

did you solve this @PRK0001 ? if so please share your solution ?

@PRK0001
Copy link
Author

PRK0001 commented Mar 5, 2024

no

@electrovir
Copy link
Sponsor

This happens to me randomly and makes my tests quite flaky.

@skullpsg
Copy link

skullpsg commented Apr 22, 2024

It is happening for me consistently. Does it Fixed?

@enkelmedia
Copy link

Struggled for many hours to get this to work with my Vite project, gave this a try https://github.com/remcovaes/web-test-runner-vite-plugin and things magically worked in less than 1 minute.

This also means that my import maps from tsconfig is reused so that I don't have to duplicate them.

@bashmish
Copy link
Member

bashmish commented Apr 23, 2024

Vite can do a lot of non-standard code transformations automatically
WDS does not do that by default, which is a conscious choice to keep things close to browsers standards
I'm not sure everyone in this thread is having the same issue, even though the logs show the same, it can be just some dependency what WDS can't not process because it's not standard ESM, or not even a JS file (CSS imports and such)
ideal we need more input, like a repository where this can be reproduced, to investigate each particular case and check if it's a bug on our side or just a non-standard dependency for which we can recommend smth on an individual basis

@electrovir
Copy link
Sponsor

I am now getting this error consistently with @web/dev-server-rollup version 0.6.2. Version 0.6.1 does not have this problem. For some reason, 0.6.2 is trying to resolve some package imports (like import {whatever} from 'package-name';) from way outside of my repository (the path does not even include a node_modules path).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants