bugra
bugra

Reputation: 75

Cypress error: Could not find any test to run

I am doing a unit test. Cypress now gives an errror. it cannot find the test. but in the login.js file I have written code. I don't understand why it can't find the test, it does exist.

the testcode:

describe("login", () => {
beforeEach(() => {
    cy.visit("http://localhost:8080");
});

});

The error:

integration\login.js

We could not detect any tests in the above file. Write some tests and re-run.

Path:

server/cypress/integration/pad/login.js

Upvotes: 5

Views: 17510

Answers (2)

Gerson Dantas
Gerson Dantas

Reputation: 1363

just edit the file... from your project's root folder to bypass cypress. Try that too to test, here it worked.

{
 //... other file settings
 "exclude": ["src/main/test/cypress"]
}

note: If you are using eslint, you will have to do one more configuration. Since eslint doesn't let us have a TypScrip file inside the project without being treated.

First: Create a file in the project root called tsconfig-eslint.json. It will extend the other tsconfig but ignore the deletion. Put the following content in it:

{
 "extends": "./tsconfig.json",
 "exclude": []
}

Second: modify the parseOptions of the .eslint.json file to point to the newly created file:

{
 //... rest of the settings
 "parserOptions": {
   "project": "./tsconfig-eslint.json"
  },
}

Upvotes: 0

octoplus
octoplus

Reputation: 76

If this is all of your test code, it really doesn't have any test. Add any 'it' and cypress will recognize it as a test.

describe("login", () => { 
    beforeEach(() => {
        cy.visit("http://localhost:8080");
    });

    it('Example test', () => {
        expect(add(1, 2)).to.eq(3)
    })

});

Upvotes: 4

Related Questions