-
Notifications
You must be signed in to change notification settings - Fork 14
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
jest and serverless both clash to use -c or --config to specify config file #11
Comments
Hi @sylvainlegault - specifying a separate Jest config should be no issue whatsoever. In your
One other potential issue could be that the If none of those appear to be related, perhaps you could share your Jest configuration (or relevant portions) to help narrow down the culprit. |
thanks for the quick answer, I simplified it now to remove typescript and root and module mapping.
but still the same
I execute at the root of the project so all config files are in the current directory. thanks in advance |
i'm using jest 25.1.0 and serverless 1.65.0 ? |
@sylvainlegault - Thanks for the update. I'm trying to put together a small environment to try to replicate. In case you'd like to see if it helps out at all, I did create a Jest 25.x branch, so you're welcome to give that a shot in the meantime. |
@sylvainlegault - I was able to track down the source of the issue: Serverless itself is naively parsing the command-line arguments along with Jest, so I just need to check to see if there's a simple way to prevent that from occurring and you should be all set! I'll keep you posted. |
@sylvainlegault I've updated my jest-25.x branch with a simple fix that should resolve your issue. When you get a chance, give it a shot and let me know if it works. I think if everything looks OK, I'll probably go ahead and publish this out to NPM as a v0.3.0 update. |
Hi Doug, great support, thanks for the fix, it is working. 👍 Can I ask one more thing, not sure if it is supported but can we specify the stage ? If I pass it as param, jest complains that it is not recognized Unrecognized option "stage". |
@sylvainlegault - because both Jest and Serverless are (by default) attempting to parse the command-line arguments, the safest solution was to disable that behavior for Serverless. I've often managed our stages via an environment variable, for example: provider:
name: aws
region: ${env:AWS_REGION, 'us-east-1'}
runtime: nodejs12.x
stage: ${env:STAGE, 'dev'} This would allow you to control the stage easily at runtime with
or even pre-define them within your "scripts": {
"test": "./node_modules/.bin/jest",
"test-e2e": "./node_modules/.bin/jest --config jest.config.e2e.js",
"test-e2e-prod": "STAGE=prod ./node_modules/.bin/jest --config jest.config.e2e.js"
} |
Sound good, thanks Doug for the help |
Hi Doug, would it be possible to create a new version on npm with this fix ? thanks |
@syl20lego I published this to NPM as I'll have to look into publishing an update to NPM that points the main repo at my fork, since I don't believe that there is anyone left at FireEye to maintain this project. |
Perfect thanks I got it. |
Interesting plugin, but sadly I need to specify a jest config file and this seems to conflict with severless that both use the same synthax to specify the file. Would it be possible to provide an overwrite for serverless. I have a feeling that most likely not an issue with your module, but if you could look to see if something possible.
jest --config jest.config.e2e.js
FAIL src/e2e/get.test.ts
● Test suite failed to run
Here serverless think that jest.config.e2e.js is the serverless.yml file
The text was updated successfully, but these errors were encountered: