I am trying to use TestCafe to automate my project's initial setup. In the middle of the setup, a POST request that takes a long time has to be made before the setup could continue. This is my runner.js
and it's running in Node 10:
const longRunningPostRequest = require('./setup/seed-database');
const createTestCafe = require('testcafe');
const RUN_OPTIONS = {pageLoadTimeout: 120000, selectorTimeout: 15000};
const setupLicense = async () => {
const testcafe = await createTestCafe('localhost', 1337, 1338, undefined, true);
const runner = testcafe.createRunner();
const failedCount = await runner
.src(['fixtures/setup-license.js'])
.browsers(['chrome -incognito'])
.run(RUN_OPTIONS);
await testcafe.close();
};
const setupData = async () => {
const testcafe = await createTestCafe('localhost', 1337, 1338, undefined, true)
const runner = testcafe.createRunner();
await runner
.src(['fixtures/setup-wizard.js'])
.browsers(['chrome -incognito'])
.run(RUN_OPTIONS);
await testcafe.close();
};
// running them all in sequence
setupLicense()
.then(() => longRunningPostRequest()) // long-running POST request. Typically takes around 100 seconds to complete
.then(() => setupData())
.catch(err => console.log('Error occured:', err));
When I run the application node runner.js
, they are working. However, only the results of the fixtures in setup-license.js
gets displayed, while the fixtures from the second runner fixtures/setup-wizard.js
do not show any output (but they are being run and are working), but it's very annoying to work with since if it fails, the error message gets swallowed as well. The workaround I did was to comment out the content of the setupLicense
fixture so that setupData
's outputs appear.
How do I go about resolving this?
Try using the latest testcafe@0.23.3 version. The team recently fixed a bug that could cause such issues - TestCafe closed the stdout
output stream when no explicit reporter was specified. This prevents any test results to be displayed in second and consecutive test sessions starting from one script file.
As a workaround, you can enable the spec reporter explicitly by adding the .reporter('spec') call to your setup code as it is shown in this example:
gist.github.com/AndreyBelym/c9afd908d4b2891a62a4ba87623ec064