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

[Bug?]: Can't configure Jest/Vitest to run tests inside of scripts dir #10834

Open
1 task
cannikin opened this issue Jun 17, 2024 · 0 comments
Open
1 task
Labels
bug/confirmed We have confirmed this is a bug topic/testing

Comments

@cannikin
Copy link
Member

What's not working?

If someone wants to create tests for their scripts, there doesn't seem to be a way to easily configure jest/vitest to run those tests. The test file(s) in /scripts are ignored.

You can trick them into running with the following command:

yarn rw test --projects scripts *

You see a warning printed quickly:

● Validation Warning:

  Unknown option "projects" with value ["<rootDir>/{*,!(node_modules)/**/}/jest.config.js"] was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration

Then the actual test files will run and work. You see a big "Active Filters" list of files that we must be adding behind the scenes:

Test Suites: 2 passed, 2 total
Tests:       2 passed, 2 total
Snapshots:   0 total
Time:        0.335 s
Ran all test suites matching /README.md|graphql.config.js|jest.config.js|node_modules|package.json|prettier.config.js|redwood.toml|scripts|select.sql|yarn.lock/i.

Active Filters: filename /README.md|graphql.config.js|jest.config.js|node_modules|package.json|prettier.config.js|redwood.toml|scripts|select.sql|yarn.lock/
 › Press c to clear filters.

But ideally we should just run them automatically with just plain yarn rw test. This should really work for any top-level directory you create outside of web and api.

How do we reproduce the bug?

  1. Create a new Redwood app
  2. Create a test file in the /scripts directory of an app
  3. Run yarn rw test

What's your environment? (If it applies)

No response

Are you interested in working on this?

  • I'm interested in working on this
@cannikin cannikin added bug/confirmed We have confirmed this is a bug topic/testing labels Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/confirmed We have confirmed this is a bug topic/testing
Projects
None yet
Development

No branches or pull requests

1 participant