web icon indicating copy to clipboard operation
web copied to clipboard

Error: ENOENT: no such file or directory, stat '/test-mocks/prism.js'

Open andyjessop opened this issue 1 year ago • 0 comments

I'm trying to mock prismjs because there seems to be an issue with the runner not being able to pick up its exports (code works fine so I know the exports exist).

Original error:

 Browser logs:
      SyntaxError: The requested module '/__wds-outside-root__/2/node_modules/prismjs/prism.js' does not provide an export named 'highlight'

I added import map plugin: `` import { importMapsPlugin } from '@web/dev-server-import-maps';` ... importMapsPlugin(),


I added the import map with the path to my mock file:

testRunnerHtml: (testFramework) => `

`, ```

folder structure is like:

- src
- test-mocks
  - prism.js
web-test-runner.config.mjs

Then I get this error:

Error while handling server request.
[Error: ENOENT: no such file or directory, stat '/test-mocks/prism.js'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'stat',
  path: '/test-mocks/prism.js',
  expose: true,
  statusCode: 404,
  status: 404
}
src/components/markdown/markdown.btest.ts:

 🚧 Browser logs:
      TypeError: Failed to fetch dynamically imported module: http://localhost:8080/src/components/markdown/markdown.btest.ts?wtr-session-id=qOWQX266tUzItfYfyr75g&wds-import-map=0&wds-import-map=0

 ❌ Could not import your test module. Check the browser logs or open the browser in debug mode for more information.

How can I debug this? What is the import map path relative to?

andyjessop avatar Jan 31 '24 10:01 andyjessop