Tests are not run when express is required in the test file
See original GitHub issueIt seems Cypress stops executing tests as soon as the express package is required within a test file.
Sample test file:
// ./cypress/integration/test_spec.js
var express = require("express");
describe("test", function() {
it("case", () => {
throw new Error("should fail");
});
});
Running this test through cypress run
gives this:
If the require
call is commented, the test fails as expected.
My environment:
$ node --version
v6.0.0
$ cypress --version
Cypress CLI: 0.13.1
Express package version installed in node_modules
: 4.14.1
.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
'app.address is not a function' when testing an express HTTPS ...
js file and I run node app.js , then the app starts fine, although the test produces the same error. test_node/app.js var https...
Read more >How to correctly unit test Express server - Gleb Bahmutov
Something is not right! First, why do we want to start and stop the server for each unit test? Aside from testing a...
Read more >How To Start Unit Testing Your Express Apps
One last trick: you can run mocha . --recursive to run all test files recursively in the current directory, and you can run...
Read more >Get started with unit testing - Visual Studio (Windows)
In this article. Create unit tests; Run unit tests; View live unit test results (Visual Studio Enterprise); Use a third-party test framework ...
Read more >Code Coverage - Cypress Documentation
js file after running the test. Selectors code coverage. Our unit test is hitting the line we could not reach from the end-to-end...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In case it’s helpful to anyone, I’ve found having this in my
package.json
works:(using cypress 2.0.4).
We have not been opinionated about the server setup / teardown other than what we have in our public projects for CI scripts.
The reason is that the vast majority of our users only need to programmatically boot webservers in CI. Our users typically iterate in the headed browser all day so there’s not really ever a “start” and an “end” event. This is part of what separates Cypress from other browser automation tools. We’re like a long running experience which you use to drive, develop, and debug your application code all day.
Running headlessly from start to stop is really only useful in CI, its just not practical to run locally.
Since cypress can be spawned programmatically you could just write a simple wrapper using
child_process
in node.We are actually in the middle of rewriting our CLI tool to be a requireable
node_module
which will have a nice API to do these things for you.Here’s the open issue for that with some example API code.