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

[Feature Request] Add way of running a script as a "before run" that runs before Jest executes #123

Closed
kevjames3 opened this issue Nov 18, 2020 · 3 comments

Comments

@kevjames3
Copy link

This issue was discovered while digging into this: nodejs/node#20432

Effectively, I am trying to debug one test, but I need NODE_EXTRA_CA_CERTS to be set before Jest executes. This variable cannot be set at runtime.

Currently, the workaround is to go to my Node Debug console in VSCode and set the variable there. Then I can debug each individual test. I notice that when I click "Debug", what is outputted a command line is generated. I simply want to prepend a "before run" hook to where I can set an ENV before Jest executes.

@firsttris
Copy link
Owner

in settings with

"jestrunner.debugOptions": {}

you can add stuff to the debug console...

https://github.com/firsttris/vscode-jest-runner/blob/master/src/jestRunner.ts#L109

would it be possible to add a varialbe to the debug console using this feature?

@kevjames3
Copy link
Author

kevjames3 commented Nov 18, 2020

So I tried this

"jestrunner.debugOptions": {
       "argv": [" export NODE_EXTRA_CA_CERTS=resources/security/certificate.pem "]
    }

And what outputted was

Warning: Ignoring extra certs from `resources/security/certificate.pemcd`, load failed: error:02001002:system library:fopen:No such file or directory

For some reason, it is appending "cd". Am I doing this right? I double checked that the file exists

@firsttris
Copy link
Owner

firsttris commented Nov 19, 2020

refering to
https://create-react-app.dev/docs/debugging-tests/#debugging-tests-in-visual-studio-code

i think i should be simple as this

"jestrunner.debugOptions": {
       "env":{
            "NODE_EXTRA_CA_CERTS": "resources/security/certificate.pem"
         }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants