testcafe
testcafe copied to clipboard
Node.js unit testing
Are you requesting a feature or reporting a bug?
feature
What is the current behavior?
TestCafe supports e2e testing only
What is the expected behavior?
TestCafe could support node.js unit testing as well. "One tool to rule them all"
I'm looking at adding unit and end-to-end tests to a large, mature web app... and if I could go with a single solution I would.
I'm interested in having TestCafe being able to run unit tests, but I'd see more value if it could run them on real browsers, as for e2e, otherwise there are many solutions for running tests on node.js. Afaik only karma support unit tests on real-browsers. Unit tests on node.js are supported by many but that way your tests run on the only engine that nobody uses among your users. TestCafe may strive for more.
@riquito Thanks for you idea. It requires careful consideration (because it should be new API, new approach..). I'm not sure we're ready to do it right now but we can consider it in the future.
I think your team should focus more on http testing. Like postman or supertest.
@devdelpiero TestCafe already has some functionality for intercepting HTTP Requests. Please refer to the following article: https://devexpress.github.io/testcafe/documentation/test-api/intercepting-http-requests/ At the moment we think that implemented functionality is sufficient to satisfy needs of most users, so at this moment we don't have plans of moving in this way.
Yes, that would be a nice addition. Something like what Cypress advertises - Unit, Integration and End-End tests
If you could just add some configuration option to fixture and/or test so that I can prevent the browser from starting it would be really easy to use testcafe for both api and end-to-end tests in the same suite. Starting the browser can be very slow so would be great if that could be stopped.
@cattermo Thank you for your suggestion. You can run TestCafe without specifying the testing page and in headless browser mode. In this case, the test would be launched much faster.
For example:
fixture ('Fixture');
test('test', async => {
//test API
});
@cattermo There is still no way to avoid opening a browser when TestCafe test execution starts. However, in 1.20.0+, TestCafe offers the t.request
method designed for API testing.
@cattermo There is still no way to avoid opening a browser when TestCafe test execution starts. However, in 1.20.0+, TestCafe offers the
t.request
method designed for API testing.
I agree, is there any way just running API tests using TestCafe and without opening browser at all?
@jiteshsojitra You can use headless
mode. Unit testing isn't supported.
@jiteshsojitra You can use
headless
mode. Unit testing isn't supported.
Yes, that alternative is not bad. It would be great, if testcafe gives a way by excluding browser stuff for API tests and would be huge benefit as a tool to all. I think, it will be highly appreciated for this feature and may create huge demand for TestCafe tool.
Will it not take any system/browser resources if headless
mode used?
A headless browser is just like any other browser, the only difference is we cannot see anything on the screen. Here we can say that the program actually runs in the backend and nothing can be viewed on the screen. Thus, it is known to be the one without a Head/GUI.
Yes, that is true. It behaves as described.
Hi folks,
We decided not to introduce the all-in-one
tool. We want to focus on implementing E2E-specific features. Please use mocha
, ava
, and other tools to run Node.js unit tests. Also, you can use the built-in Node.js test runner.