Reputation: 1031
I have a project created with vue-cli which uses mocha for unit testing (default setting). I want to write a unit test, but I fail with following setting:
My project folder:
I fail with the following error messages:
WARNING in ./src/assets/css/variables.styl
Module build failed: ParseError: /Users/kevin.hu/Documents/vreditor/src/assets/css/variables.styl:4:154
1| // style-loader: Adds some css to the DOM by adding a <style> tag
2|
3| // load the styles
4| var content = require("!!../../../node_modules/css-loader/index.js??ref--12-1!../../../node_modules/stylus-loader/index.js??ref--12-2!./variables.styl");
---------------------------------------------------------------------------------------------------------------------------------------------------------------^
5| if(typeof content === 'string') content = [[module.id, content, '']];
6| if(content.locals) module.exports = content.locals;
7| // add the styles to the DOM
So I want to run the test skipping the assets folder or other ones. The default setting just excludes main.js. How to write a regular expression to acheive what I want?
Note: this is the default setting:
const srcContext = require.context('../../src', true, /^\.\/(?!main(\.js)?$)/)
srcContext.keys().forEach(srcContext)
Upvotes: 0
Views: 852
Reputation: 89584
Perhaps something like this:
const srcContext = require.context('../../src', true, /^\.\/(?!main(\.js)?$|assets(?![^\/]))/)
It uses the same negative lookahead to exclude assets. (?![^\/])
means not followed by a character that isn't a slash, in other words: followed by a slash or the end of the string.
If you want to exclude other folders, it is shorter to put (?![^\/])
in factor using a non-capturing group:
/^\.\/(?!main(\.js)?$|(?:folder1|folder2|folder3)(?![^\/]))/
Upvotes: 1