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: ENOENT: no such file or directory, stat '/test-mocks/prism.js' #2629

Open
andyjessop opened this issue Jan 31, 2024 · 0 comments
Open

Comments

@andyjessop
Copy link

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) => `

<script type="importmap"> { "imports": { "prismjs": "./test-mocks/prism.js" } } </script> <script> window.process = {env: { NODE_ENV: "production" }} </script> <script type="module" src="${testFramework}"></script> `, ```

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?

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

1 participant