Open ShivamJoker opened 3 years ago
@ShivamJoker are you able to share a repo with a recreation of this situation?
I'm not acquainted with @snowpack/web-test-runner-plugin
and whether the build tooling that this binds itself to requires the code to be colocated to build the files under test in this case. Have you discussed this with anyone at https://discord.com/invite/snowpack to be sure you're consuming that plugin as expected?
@Westbrook here is the repo link https://gitlab.com/realdevexp/easy-collab-frontend/-/tree/15-fix/api-config
The branch is 15-fix/api-config
I have looked into the docs and examples many times to check if everything is being configured properly or not.
If you have any other way to run tests without using the @snowpack/web-test-runner-plugin
, please let me know.
And even if I remove the whole config file I still get the same error 😢
I noticed this as well, and I solved it by checking in my snowpack.config.js if process.env.NODE_ENV is "test", and if so, I add a mount for the test files.
@IanVS can you please share the minimal config to get it working ?
@ShivamJoker here's an example with most of the rest of the config stripped out:
const IS_TESTING = process.env.NODE_ENV === 'test';
const mount = {
public: { url: '/', static: true },
src: { url: '/dist' },
};
if (IS_TESTING) {
mount['test-setup'] = { url: '/test-setup' };
}
module.exports = {
mount,
plugins: [],
routes: [],
optimize: {},
packageOptions: {
polyfillNode: IS_TESTING,
},
devOptions: {},
buildOptions: {},
};
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.
Hey thanks @IanVS it works. But I'll leave this open because still it should be implemented by library.
Thanks, it worked!
@ShivamJoker what would you suggest should be implemented?
When I put my whole
tests
folder inside thesrc
directory everything seems to work but if I put it in root it starts giving the error.Script
If someone can help, it would be great or if it's a bug then please provide some workarounds.