question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

mocha Done() not find when using Typescript

See original GitHub issue

https://docs.cypress.io/api/events/catalog-of-events.html#App-Events has multiple examples using done()

I’m using typescript and in the following piece of code:

cy.on('window:load', (win) => {
     ....
     done();
});

i get the following error: [ts] cannot find name ‘done’

my tsconfig.json has the following includes:

  "include": [
    "node_modules/cypress",
    "cypress/**/*.ts"
  ],

Desired behavior:

I expected the done to be recognised as valid.

Versions

Cypress: 3.0.1. Beta OS: Win 7 Browser: Chrome 64

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
chrisbreidingcommented, Jun 21, 2018

done is not a global and has to be used in the scope of an it, before, or beforeEach block, like so:

it('is a test', (done) => {
  cy.on('window:load', (win) => {
     ....
     done()
  })
})

I’d need to know more about what you’re doing to be sure, but it looks like what you’re trying to do is unnecessary. If you use cy.visit(), Cypress already waits until the load event fires on the page to run subsequent commands, so there’s no need to manually wait for window:load.

0reactions
TimoPotcommented, Jun 26, 2018

cy.on(‘window:load’) is fired when the main paged is loaded. But the main page contains an iframe which also loads content.

The waitForIFRameReady() waits for the iframe to be ready and after that the waitForIFrameBody() checks for the content of the iframe to be present. If that’s the case then I do the it.

I will try your suggestion.

thx

Read more comments on GitHub >

github_iconTop Results From Across the Web

WebStorm can not find ts-node/module and describe definition ...
I am having problems setting up WebStorm with Mocha ...
Read more >
How to Fix the “Cannot Find name 'describe'” Error in TypeScript
To fix the “cannot find name 'describe'” error, install the type definitions for your testing framework, and then add the definitions to the ......
Read more >
Cannot find name 'describe' Error in TypeScript | bobbyhadz
To solve the "Cannot find name 'describe'" error, install the type definitions for your test runner, e.g. npm i -D @types/jest or npm...
Read more >
Mocha for TypeScript Testing: How to Get Started - Testim Blog
Mocha is a popular JavaScript test framework that's often used for testing Node.js applications. It's a widely used testing tool for both ...
Read more >
Unit testing JavaScript and TypeScript - Visual Studio (Windows)
NET Core and JavaScript or TypeScript, see Write unit tests for ASP.NET Core . ... For a Mocha unit test, use the following...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found