How to set timeout while doing vue-cli unit test - vue.js

I am performing vue unit through below command
vue-cli-service test:unit
Now the problem is some unit test case need the response from the server, and usually they take much time to execute.
So i want to know how to manually set the timeout for vue-cli unit tests
Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure
"done()" is called; if returning a Promise, ensure it resolves.

Try as below
vue-cli-service test:unit --timeout, -t timeout threshold in milliseconds

Related

vue-router Failed to resolve async component default: ChunkLoadError: Loading chunk vendors~demo failed

I wrote my program with Laravel and Vuejs and it works fine on the localhost, but it gets an error on the host.
Problem:
The program runs well on local host, but when I put it on the host, the following error is appears:
[vue-router] Failed to resolve async component default:
ChunkLoadError: Loading chunk vendors~demo failed
ChunkLoadError: "Loading chunk vendors~demo failed.
(missing: http://example.com/vendors~demo.js)"
requireEnsure http://example.com/js/manifest.js:127
component webpack-internal:///./resources/js/router.js:56
resolveAsyncComponents webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:1904
flatMapComponents webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:1931
flatMapComponents webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:1931
flatMapComponents webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:1930
resolveAsyncComponents webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:1866
iterator webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:2121
step webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:1847
step webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:1851
step webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:1851
step webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:1848
iterator webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:2140
_callee$ webpack-internal:///./resources/js/permission.js:109
What I did:
I assumed that the files might not be properly located on the host, but that was not the problem.
The next possibility was to update Webpack, but that didn't solve the problem.
Where is the problem?
After several attempts, I used the following command to get the compiled js files, which was a mistake. These are good for development purposes.
npm run watch
or
yarn watch
Use the following command to get the output:
npm run prod

how should i fix jest integration test errors causing due to timeout?

I'm getting inconsistent results when every I run npm test
Sometimes all test pass and most of the time one or the other test fails due to this error:
Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.
at node_modules/jest-jasmine2/build/queue_runner.js:68:21
at Timeout.callback [as _onTimeout] (node_modules/jsdom/lib/jsdom/browser/Window.js:678:19)
I have noticed when ever test files name is printed twice or thrice some test fails.
I'm using WSL to run the tests and I have configured jestjs like this:
"scripts": {
"test": "jest --watchAll --verbose --coverage"
},
"jest": {
"testURL": "http://localhost/"
},
how should I configure jest so the tests run properly or fix this inconsistent behavior?

How can i get the result of a test (fail/pass) written in to a variable/file when testing with Detox on TravisCI

Im building my React Native app with TravisCI and using Detox to run E2E on the version.
The Detox test results are printed to the travis console but i need to know fail or pass in an env var so i could act on it.
The test command is:
detox test --configuration ios.sim.debug
So i've tried:
export SANITY_RES=$(detox test --configuration ios.sim.debug)
but echo $SANITY_RES only contains:
configuration="ios.sim.debug" artifactsLocation="artifacts/ios.sim.debug.2018-12-25 14-42-58Z" node_modules/.bin/jest e2e --config=e2e/config.json --maxWorkers=1 '--testNamePattern=^((?!:android:).)$' detox[80481] INFO: [DetoxServer.js] server listening on localhost:51067...*
and not the final result.
Any other way i could get them ?
Detox allows you the ability to write logs of your builds. See for more details https://github.com/wix/Detox/blob/master/docs/APIRef.Artifacts.md
If you add —record-logs all as a flag to your detox test it will save all the logs of the build, change it to —record-logs failing if you only want logs of failing tests.
You can even specify where the logs will be stored.

How to customize botium mocha timeout

I am trying to connect to directline using the following setup:
botium_directline.json:
{
"botium": {
"Capabilities": {
"PROJECTNAME": "botium-sample1",
"CONTAINERMODE": "directline3",
"DIRECTLINE3_SECRET": "<BOTIUM_SECRET>",
"DIRECTLINE3_WEBSOCKET": true
},
"Sources": {},
"Envs": {
"NODE_TLS_REJECT_UNAUTHORIZED": 0
}
}
}
Folder structure:
If I run:
botium-cli emulator browser --convos ./spec/convos --config ./botium_directline.json
I am able to "communicate with the bot" within the new conversation.
If I wanna run the tests I prepared I get the following timeouts:
botium-cli run --convos ./spec/convos/ --config ./botium_directline.json
user # /Users/username/workspace/testing/botium
~~ npm test
> botium#1.0.0 test /Users/username/workspace/testing/botium
> botium-cli run --convos ./spec/convos/ --config ./botium_directline.json
Botium Test-Suite
1) Test One
2) Test Two
0 passing (4s)
2 failing
1) Botium Test-Suite
Test One:
Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
2) Botium Test-Suite
Test Two:
Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
The error is similar to a standard mocha timeout error, but I do not know where to put a .js file to increase the timeout in a beforeEach.
I attempted to add both BOTIUM_TIMEOUT or a TIMEOUT properties into the botium_directline.json but this did not do anything.
Any ideas how to increase the timeout?
Botium automated tests have default timeout of 60000 milliseconds, but you can customize it by passing the --timeout flag at the end of your CLI command.
To do that, just add the flag --timeout followed by the time in milliseconds you'd like to set it up for. For instance, for 100000 milliseconds, your command should be like this: botium-cli emulator browser --convos ./spec/convos --config ./botium_directline.json --timeout 100000
The "BOTIUM_TIMEOUT" environment variable is the correct choice, or you can use the "--timeout" command line switch for botium-cli. This is only available since some days, there was a bug involved which has been fixed. Please get the build 0.0.34 of the botium-cli:
npm install botium-cli#0.0.34

gulp-npm-test running Jest tests (all passing), but claiming to fail

I've installed gulp-npm-test following their documentation, that is, in my gulp directory I've got a file test.js that looks like this:
var gulp = require('gulp')
require('gulp-npm-test')(gulp)
var gulp = require('gulp-npm-test')(gulp, {
withoutNpmRun: false
})
But when I run gulp test I get the output like the following:
[17:12:41] Using gulpfile ~/my-project/gulpfile.js
[17:12:41] Starting 'test'...
> my-project#0.0.1 test /Users/wogsland/my-project
> jest
PASS frontend/tests/components/atoms/InputText.test.js
.
.
(many more Jest test passes, no fails)
.
.
FAIL gulp/tasks/test.js
● Test suite failed to run
Your test suite must contain at least one test.
at onResult (node_modules/jest/node_modules/jest-cli/build/TestRunner.js:192:18)
Test Suites: 1 failed, 135 passed, 136 total
Tests: 135 passed, 135 total
Snapshots: 209 passed, 209 total
Time: 92.237s
Ran all test suites.
npm ERR! Test failed. See above for more details.
What am I missing here? I've go a bunch of tests
Looks like the matcher that figures out which files are tests, matches everything that includes in the filename test.js. The default is [ '**/__tests__/**/*.js?(x)', '**/?(*.)(spec|test).js?(x)' ]. So either adapt this one, its testMatch in your jest settings. Or use testPathIgnorePatterns to exclude the /gulp folder.