However, a common pattern in JS land is to gather all your tests in a __tests__ directory (we follow this pattern in the framework itself in many places):
With this directory structure in an app Jest thinks that everything in __tests__ is a test file and so tries to execute the scenarios file as if it was a test and raises an "empty test file" error:
This particular bug only applies to the api side, but I imagine something similar will happen if you place *.mocks.js files from the web side into a __tests__ directory as well.
I was able to work around this by updating the api/jest.config.js file in the api side:
But I think ignoring them should be the default behavior of the framework.
The easiest fix would be to update CRA to generate the config file like this, but ideally our internal Jest config would specify this option automatically, leaving this config file nice and clean by default.
This should not be a breaking changes as we already "reserve" the scenarios.js filename and so I don't think anyone would be relying on this (incorrect) behavior currently.
How do we reproduce the bug?
Generate a redwood app
Generate a random service like users
Move the users.test.js and users.scenarios.js files to a __tests__ subdirectory
What's not working?
By default Redwood generates tests and scenarios as "sidecar" files next to the thing they're testing:
However, a common pattern in JS land is to gather all your tests in a
__tests__
directory (we follow this pattern in the framework itself in many places):With this directory structure in an app Jest thinks that everything in
__tests__
is a test file and so tries to execute the scenarios file as if it was a test and raises an "empty test file" error:This particular bug only applies to the api side, but I imagine something similar will happen if you place
*.mocks.js
files from the web side into a__tests__
directory as well.I was able to work around this by updating the
api/jest.config.js
file in the api side:But I think ignoring them should be the default behavior of the framework.
The easiest fix would be to update CRA to generate the config file like this, but ideally our internal Jest config would specify this option automatically, leaving this config file nice and clean by default.
This should not be a breaking changes as we already "reserve" the
scenarios.js
filename and so I don't think anyone would be relying on this (incorrect) behavior currently.How do we reproduce the bug?
users
users.test.js
andusers.scenarios.js
files to a__tests__
subdirectoryyarn rw test api
What's your environment? (If it applies)
No response
Are you interested in working on this?