Not able to run tests if test files are not inside src directory using Snowpack
See original GitHub issuetests/App.test.jsx:
🚧 Browser logs:
TypeError: Failed to fetch dynamically imported module: http://localhost:8000/easy-collab-frontend/tests/App.test.jsx?wtr-session-id=b3ca1529-8150-4d2c-b050-5a62560ca4c0
When I put my whole tests
folder inside the src
directory everything seems to work but if I put it in root it starts giving the error.
// App.test.jsx
import React from 'react';
import { render, screen } from '@testing-library/react';
import { expect } from 'chai';
import '../src/internationalization/index';
import App from '../src/components/App';
describe('App', () => {
it('renders App component', () => {
render(<App />);
const unauth = screen.getByText('Unauthorized Access!!');
expect(document.body.contains(unauth));
});
});
// web-test-runner.config.js
process.env.NODE_ENV = 'test';
const str = require('@snowpack/web-test-runner-plugin')();
module.exports = {
testFramework: {
config: {
ui: 'bdd',
timeout: '2000',
},
},
plugins: [str],
coverageConfig: {
exclude: ['**/*/_snowpack/**/*'],
},
};
Script
"test": "web-test-runner \"tests/**/*.test.jsx\" --node-resolve",
If someone can help, it would be great or if it’s a bug then please provide some workarounds.
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (1 by maintainers)
Top Results From Across the Web
Bug: @snowpack/web-test-runner coverage #2157 - GitHub
I mount /src to / ) then any code coverage report generated by web test runner is broken because it fails to locate...
Read more >snowpack.config.js
"test" : testOptions.files are not excluded, and will be scanned & built as normal source files. Useful when running tests on top of...
Read more >Snowpack 3.8 cannot find the source folder, running dev ...
I would like my index.html file to be in the src directory, but then snowpack does not find the index.html file. When starting...
Read more >Parcel
Parcel automatically tracks all of the files, configuration, plugins, and dev dependencies that are involved in your build, and granularly invalidates the cache ......
Read more >Jest 27: New Defaults for Jest, 2021 edition
In the Jest 26 blog post about a year ago, we announced that after two ... of defaults and other notable breaking changes...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@ShivamJoker here’s an example with most of the rest of the config stripped out:
In my case, I put my actual test files next to my components in
/src
, but I have some setup files that I only want to mount when I’m testing. You could do something similar for your/tests
directory.@ShivamJoker what would you suggest should be implemented?