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.

Tests doesnt work outside of libs and apps scope

See original GitHub issue

Current Behavior

If you add a test file inside tools/generators directory, jest throws:

No tests found, exiting with code 1

Expected Behavior

Tests should work as expected

Steps to Reproduce

Create a test file in tools/generators/sum.spec.ts

describe('some test', async () => {
  it('test sum', function () {
    const num = 1 + 1
    expect(num).toBeGreaterThanOrEqual(2)
  })
})

Failure Logs


No tests found, exiting with code 1
Run with `--passWithNoTests` to exit with code 0

Environment

Node : 14.17.4 OS : darwin x64 yarn : 1.22.11

nx : Not Found @nrwl/angular : Not Found @nrwl/cli : 12.8.0 @nrwl/cypress : 12.8.0 @nrwl/devkit : 12.8.0 @nrwl/eslint-plugin-nx : 12.8.0 @nrwl/express : 12.8.0 @nrwl/jest : 12.8.0 @nrwl/linter : 12.8.0 @nrwl/nest : Not Found @nrwl/next : Not Found @nrwl/node : 12.8.0 @nrwl/nx-cloud : Not Found @nrwl/react : 12.8.0 @nrwl/schematics : Not Found @nrwl/tao : 12.8.0 @nrwl/web : 12.8.0 @nrwl/workspace : 12.8.0 @nrwl/storybook : 12.8.0 @nrwl/gatsby : Not Found typescript : 4.3.5

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
jaquacommented, Sep 26, 2021

@vsavkin I also created some scripts and generators in the tools directory. Of course I added all the needed unit tests for those scripts, but they won’t be tested by nx test or nx affected:test - although those files will have affect on the whole project, if the scripts have any bugs. I do not understand your suggestion to create a project. Do you mean an application or a library? And if yes, what kind of library?

1reaction
vsavkincommented, Sep 15, 2021

Hi there.

We don’t encourage folks to run jest from the root and instead encourage them to use nx affected --target=test. The command then will only test the affected projects instead of all of them. I imagine you are running the jest command directly. You can do it but in this case you rerun all tests on all PRs.

What I would suggest instead is to create a project in workspace.json and set its root to tools/generators.

Does it make sense?

Read more comments on GitHub >

github_iconTop Results From Across the Web

nx test: Jest unit tests are failing to run in any test that ... - GitHub
Current Behavior An NX - Ionic and Vue workspace fails to run tests, many solutions tested and any seems to fix the issue:...
Read more >
"No such module" when using @testable in Xcode Unit tests
Please check your Module Name that you try to import with @testable import "ModuleName" . The module name should be the same on...
Read more >
New features in Android Studio Preview - Android Developers
This page lists the new features introduced in Android Studio preview releases. The preview builds provide early access to the latest features and ......
Read more >
Usage of Angular libraries published to npm
Run or restart the ng serve Angular CLI command to see Bootstrap 4 work in your application. Using runtime-global libraries inside your applink....
Read more >
Top 18 Most Common AngularJS Developer Mistakes - Toptal
Single page apps demand the front-end developers to become better software ... set foo in the inner scope to 2, but will not...
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