rei / vunit Goto Github PK
View Code? Open in Web Editor NEWWrite unit tests against your Vue components using mocha and @vue/test-utils
License: MIT License
Write unit tests against your Vue components using mocha and @vue/test-utils
License: MIT License
Currently all tests require webpack build and jsdom. We'd like to run mocha only if you are only testing vanilla js.
Here are example test scripts of the capability we want to capture:
"test-coverage": "vunit --coverage --spec=\"./src/test/js/**/*.?(vue-)spec.js\"",
"test-js": "cross-env BABEL_ENV=test mocha --require @babel/register --recursive src/test/js/**/*.spec.js",
"test-js-coverage": "cross-env BABEL_ENV=test nyc mocha --require @babel/register --recursive src/test/js/**/*.spec.js",
"test-js-coverage-report": "cross-env NODE_ENV=test nyc --reporter=lcov mocha --recursive src/test/js/**/*.spec.js",
"test-js-watch": "cross-env BABEL_ENV=test mocha --require @babel/register --watch --recursive src/test/js/**/*.spec.js",
This popped up while trying to write tests that involved sessionStorage
- there's no way to do things like change jsdom's window.location.href
without having access to the jsdom instance itself.
Can we expose a reference to it as a global in setup script?
Can we whitelist --require
as an accepted cli argument so users can configure mocha with additional global setup files?
Desired functionality
Be able to add the following script to the package.json
file and have it pull in a config file for mocha
"scripts" : {
"test": "vunit --spec=./test/**/*.spec.js --require=./test/setup.js"
}
Current functionality
Adding the script returns Invalid option given: require
Getting below error as a result of an @import ...
in <style>
section:
watched directories:
webpack config: ...frontend/node_modules/@rei/vunit/webpack.config.js
specGlob: ./test/**/*.spec.js
--------------------------------
Setting up JSDOM...OK.
WEBPACK Compiling...
WEBPACK Compiled successfully in 1090ms
MOCHA Testing...
RUNTIME EXCEPTION Exception occurred while loading your tests
.../frontend/node_modules/@rei/cdr-icon/dist/cdr-icon.css:1
(function (exports, require, module, __filename, __dirname) { .cdr-icon-sprite{display:none}.cdr-icon_1\.0\.0{display:inline-block;vertical-align:middle;-ms-flex:0 0 auto;flex:0 0 auto;width:2.4rem;height:2.4rem;fill:#292929}.cdr-icon--sm_1\.0\.0{width:1.6rem;height:1.6rem}.cdr-icon--lg_1\.0\.0{width:3.2rem;height:3.2rem}.cdr-icon--inherit-color_1\.0\.0{fill:inherit}
^
SyntaxError: Unexpected token .
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:616:28)
at Module._extensions..js (module.js:663:10)
at Object._module2.default._extensions.(anonymous function) [as .js] (..../frontend/node_modules/mocha-webpack/lib/util/registerRequireHook.js:140:62)
Create a programmatic API for integration with other tools.
When updating to nyc
> 13, the vue test coverage drops off. Investigate and fix.
I've added a webpack.overrides.conf.js
file for febs to add a resolve alias but it looks like vunit doesn't use that file and only has an option to provide a full webpack config.
Is there some way to add just a partial config that would merge with the default one? Or do I have to get the full config from febs somehow to pass to this?
vunit
is not setting the process exit code so external scripts cannot detect when tests fail.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.