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.

Adding new test file results in "No tests found"

See original GitHub issue

Current behavior

After installing the default cypress component testing repo and adding a new component and a new test to it results in “No tests found”

Desired behavior

It should find the tests

Test code to reproduce

Start by installing react with cypress here: https://www.cypress.io/blog/2021/04/06/cypress-component-testing-react/
Now add a new component, for example, Button.tsx

import React from 'react';

const Button = ({text}: any) => {
  return <button>{text}</button>;
};

export default Button;

Now add a test to it:

import React from 'react';
import { mount } from '@cypress/react';
import Button from './Button';

it('renders button', () => {
  mount(<Button text="text"/>);
  cy.get('button').contains('text');
});

The result is:
image

Cypress Version

9.3.1

Other

No response

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
chrisrhymescommented, Feb 18, 2022

Clearing the next cache seems to fix this issue.

If I run rm -r .next/cache then npx cypress run-ct it now detects both the new test file and the tests.

0reactions
paul-moerscommented, Mar 2, 2022

Thank you @chrisrhymes, that indeed seems to do the trick!

Read more comments on GitHub >

github_iconTop Results From Across the Web

TestExplorer does not discover new tests in existing test class
Test results are sorted by class. Adding new test methods aren't discovered and silently fail to be run. Informational data from the output...
Read more >
No tests found for given includes Error, when running ...
Go to Preferences -> Build, Execution, Deployment -> Gradle -> change "Run tests using" to "IntelliJ IDEA". Run your test. Go again to...
Read more >
Configure unit tests by using a .runsettings file - Microsoft Learn
In the IDE, select Test > Configure Run Settings > Select Solution Wide runsettings File, and then select the .runsettings file. This file...
Read more >
Jest — Filenames without test or spec | by Damian Myerscough
No tests found, exiting with code 1. Run with `--passWithNoTests` to exit with code 0. In /Users/damianmyerscough/project1 4 files checked.
Read more >
How To Test a React App with Jest and React Testing Library
Both Jest and React Testing Library come pre-packaged with Create ... Output. No tests found related to files changed since last commit.
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