Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Cannot read property 'tests' of null" when using client scripts #6305

Closed
Aaronius opened this issue Jun 11, 2021 · 1 comment · Fixed by #6771
Closed

"Cannot read property 'tests' of null" when using client scripts #6305

Aaronius opened this issue Jun 11, 2021 · 1 comment · Fixed by #6771
Assignees
Labels
FREQUENCY: level 1 TYPE: bug The described behavior is considered as wrong (bug).

Comments

@Aaronius
Copy link

What is your Test Scenario?

My test scenario can be as simple as this:

fixture`Getting Started`.page`http://devexpress.github.io/testcafe/example`;

test("My first test", async t => {
  // Test code
});

But this issue isn't so much about my test scenario as it is configuring the testcafe runner with clientScripts. Here's my setup:

await testcafe
    .createLiveModeRunner()
    .clientScripts("preventSpecificErrorsFromFailingTests.js")
    .src(testsDir)
    .browsers("chrome")
    .run();

What is the Current behavior?

I receive the following error in the console:

TypeError: Cannot read property 'tests' of null
    at LiveModeRunner._finishPreviousTestRuns (/Users/aahardy/dev/reactor-extension-alloy/node_modules/testcafe/src/live/test-runner.js:151:38)
    at LiveModeRunner.runTests (/Users/aahardy/dev/reactor-extension-alloy/node_modules/testcafe/src/live/test-runner.js:36:21)
    at /Users/aahardy/dev/reactor-extension-alloy/node_modules/testcafe/src/live/test-runner.js:113:30
Error: Cannot load a client script from preventSpecificErrorsFromFailingTests.js.
    at ClientScript._loadFromPath (/Users/aahardy/dev/reactor-extension-alloy/node_modules/testcafe/src/custom-client-scripts/client-script.ts:64:19)
    at ClientScript.load (/Users/aahardy/dev/reactor-extension-alloy/node_modules/testcafe/src/custom-client-scripts/client-script.ts:91:13)
    at async Promise.all (index 0)
    at Object.default_1 [as default] (/Users/aahardy/dev/reactor-extension-alloy/node_modules/testcafe/src/custom-client-scripts/load.ts:11:5)
    at LiveModeBootstrapper.createRunnableConfiguration (/Users/aahardy/dev/reactor-extension-alloy/node_modules/testcafe/src/runner/bootstrapper.ts:419:37)

What is the Expected behavior?

A successful test run. Note that if I remove the .clientScripts("preventSpecificErrorsFromFailingTests.js") line, the test run completes just fine. Currently my preventSpecificErrorsFromFailingTests.js file contains no content, but it doesn't really matter what I put in that file.

What is your web application and your TestCafe test code?

Your website URL (or attach your complete example):
Your complete test code (or attach your test files):
 fixture`Getting Started`.page`http://devexpress.github.io/testcafe/example`;

test("My first test", async t => {
  // Test code
});
Your complete configuration file (if any):
#!/usr/bin/env node
const path = require("path");
const createTestCafe = require("testcafe");
const testsDir = path.join(__dirname, "../test/sample");

(async () => {
  const testcafe = await createTestCafe("localhost", 1337, 1338);
  const failedCount = await testcafe
    .createLiveModeRunner()
    .clientScripts("preventSpecificErrorsFromFailingTests.js")
    .src(testsDir)
    .browsers("chrome")
    .run();
  testcafe.close();
  process.exit(failedCount ? 1 : 0);
})();

Your complete test report:

N/A

Screenshots: N/A

Steps to Reproduce:

  1. Clone https://github.com/Aaronius/testcafe-bugs
  2. Checkout the client-scripts branch
  3. Run npm install
  4. Run npm test

Your Environment details:

  • testcafe version: 1.14.2
  • node.js version: 14.16.1
  • command-line arguments: None, just using the library as described.
  • browser name and version: Chrome 91
  • platform and version: Mac Catalina
  • other:
@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Jun 11, 2021
@miherlosev
Copy link
Collaborator

Hi @Aaronius

Thank you for the shared example. I've reproduced the issue.

@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Jun 13, 2021
@miherlosev miherlosev added FREQUENCY: level 1 TYPE: bug The described behavior is considered as wrong (bug). labels Jun 13, 2021
@miherlosev miherlosev self-assigned this Dec 14, 2021
@miherlosev miherlosev removed their assignment Dec 15, 2021
@miherlosev miherlosev self-assigned this Dec 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FREQUENCY: level 1 TYPE: bug The described behavior is considered as wrong (bug).
Projects
None yet
2 participants