mocha-webpack | mocha test runner with integrated webpack precompiler
kandi X-RAY | mocha-webpack Summary
kandi X-RAY | mocha-webpack Summary
mocha test runner with integrated webpack precompiler
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Registers a module using a loader .
- Exits code and exit with PhantomJS if it exists .
- Sort extensions .
- Find a config file
- Get the extension name .
- Check if a file exists
- Handles missing config options
- Checks if a file exists
- Resolves a file path
- ensure path is absolute
mocha-webpack Key Features
mocha-webpack Examples and Code Snippets
npm install --save-dev mocha-webpack
"test": "mocha './build/**/*.test.js' --compilers js:babel-core/register --require ignore-styles"
"test": "mocha-webpack --webpack-config webpack.config
Community Discussions
Trending Discussions on mocha-webpack
QUESTION
I am using vuejs in Laravel 5.7 to build an SPA. I am using mocha-webpack and vue-test-utils to write some vue component tests.
The tests can't seem to work out stylesheet imports into components. For example: I have a ExampleComponent.vue which includes the following:
...ANSWER
Answered 2019-Dec-31 at 12:00While struggling with the same issue I landed on this page - https://github.com/vuejs/vue-cli/issues/4053 and a comment from robbishop that lead me to my solution. Using the above I managed to find a configuration in webpack.mix.js that seem to work:
- First install null-loader (npm i -D null-loader)
- Add the following line in rules:
QUESTION
I am using vue-test-utils/mocha-webpack/expect to test the following component:
...ANSWER
Answered 2019-Dec-03 at 16:34The error was with the toggleMiniBasket
method:
this.miniBasketDetailShow != this.miniBasketDetailShow;
should be
this.miniBasketDetailShow = !this.miniBasketDetailShow;
QUESTION
npm run build gives
...ERROR TypeError: Cannot read property 'match' of undefined.
ANSWER
Answered 2019-Nov-23 at 09:39- clear npm cache
delete package-lock.json.
npm cache clear --force
and try to run the command:
QUESTION
I am using Vue with Webpack4. And I was installed mocha-webpack
for test. But I got a result of failed from Mocha. I think to count
is updating, so I think to pass to test. But failed. Why I got a result like this? Maybe, VirtualDom is not updating on running of test. increment
method was called on test, But not updated dom.
Test result.
...ANSWER
Answered 2019-Aug-02 at 19:42The problem is when you change count
actual DOM is not updated at that moment. So you should wait until Vue manipulate the DOM, since Vue performs DOM manipulations asynchronously.
For example, when you set
vm.someData = 'new value'
, the component will not re-render immediately. It will update in the next “tick”, when the queue is flushed. Most of the time we don’t need to care about this, but it can be tricky when you want to do something that depends on the post-update DOM state.
Exampel of code from vue-test-utilds
docs:
QUESTION
In the VueJs web application, we have written more than 500 unit test-cases(in all modules) using vue-test-utils and mocha-webpack, using nyc for coverage reports. Consider each module in one directory. When I run test-cases for a particular module, report gets generated successfully with test-case results(pass or fail). But running all test-cases in one go(by setting the path in package.json), all test-cases doesn't execute and throws following error:
Timeout of 100000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
I have seen similar questions that suggest using async await in code or increasing the timeout to resolve this, but why test-cases get executes when I run for a particular module and throws above error when I run for the whole project.
I have tried setting --timeout 100000 in package.json and it helped for large number of test-cases, but while running all(more than 500) unit test-cases again It throws the same error. I think this has to do with the number of test-cases.
What is causing this issue and How to resolve this so all test-cases runs successfully.?
Edit If any code in unit-tests is causing this timeout issue, How to detect which testcase is causing this issue, because It seems not possible to detect the source of issue by looking at logs in command prompt. Any pointers would be helpful.
...ANSWER
Answered 2019-Jul-24 at 09:27After so many resolutions tried, came to a conclusion, that resolved above issue:
- When we run test-cases, and there are dependency related warnings then It slows down test-cases and gives timeout issue. The resolution is to remove these warnings by mocking actions, mutations, getters and stubbing child components.
- Adding NODE_OPTIONS: 'node --max_old_space_size=16384' in the configuration file will increase the NodeJS memory.This has improved performance of unit-tests.
- Instead of using beforeEach, use before and after methods for mounting the components in wrapper. Also use destroy in after method to destroy the wrapper as follows:
QUESTION
I'm very new to unit Testing in vue js. I just went through this website to learn unit testing "https://vue-test-utils.vuejs.org/guides/#testing-single-file-components-with-mocha-webpack". while I'm practicing the examples in "mocha-webpack" I got this Error
...ANSWER
Answered 2018-Sep-06 at 12:44It is a problem related with version 1.14.1 of prettier
, that is a NPM package used in your scenario.
Indeed, looking at their GitHub repo the issue is reported. At the moment there is a possible workaround: basically, it is to comment out line 32893 of prettier/index.js
.
In your environment you can find the file here: /opt/htdocs/guru/unitTest_prct/node_modules/
.
QUESTION
i have existing project to make unit test with single component but when i compile will got an error.
...ANSWER
Answered 2019-Feb-27 at 06:04modifying the webpack.config file
like
QUESTION
I am trying to configure/run my first unit test for Vuejs. But I can't get past the configuration issues. I have tried installing the libraries but for some reason I keep getting errors.
Here is what an example of my code looks like:
My directory structure: ...ANSWER
Answered 2018-Apr-06 at 17:15According to the error logs you provide here, the failing tests that you spot are the End to End ones. Indeed, by executing the command npm test e2e
you're testing using Nightwatch. See under /tests/e2e/specs
. Here you should have a default test file checking that your Vue application properly create a DOM element identified as app
.
The test should be the following:
QUESTION
After creating a project with vue-cli(v3.5.1), the unit test that was auto-created is failing when I run: 'npm run test:unit'.
After running 'vue create', I manually selected the following options: TS, Router, Vuex, Linter, Unit, E2E, class-style component syntax: yes, Babel: no, history mode: no, linter: TSLint, Lint on save, unit-test solution: Mocha, E2E test solution Cypress, config files: dedicated files.
The output of 'npm run test:unit' is below.
...ANSWER
Answered 2019-Mar-20 at 14:39If, in addition to the options above, I opt to include Babel as a feature, and also use Babel alongside TypeScript for auto-detected polyfills, the unit-test runs as expected. Example of working config is below.
QUESTION
So I have a setup.js
file that I would like to execute/setup for another file.
Currently the setup file is just simply this:
...ANSWER
Answered 2018-Oct-23 at 07:16Yes, --require
or -r
can be passed as a parameter to node, and it loads the module using the same logic as the require()
call. Check the docs for details.
--require
is also implemented as an option to nyc
as you pointed out, and mentioned in their documentation
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install mocha-webpack
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page