Open IgorAufricht opened 6 years ago
@JustinGrote oh! What a pity, it would be awesome to count on a reliable API to do this. Thanks for your response.
We will be using this for the moment, but we are waiting for the final solution as many of you.
Greetings
I'm not sure that's 100% related.
@socketopp for your particular use case of using njsTrace, you can plug into jest's instrumentation framework. jest will have main()
, so to speak, but njsTrace or instanbul or whatever else can be called.
It is a pity that Jest didn't take the same approach as React, but is instead is a tangled framework that does everything from compilation to module resolution to test helpers.
So apparently it is still a no-no, am I wrong?
Still a no-no AFAIK :(
From: Rodrigo Gomes da Silva @.> Sent: Saturday, January 29, 2022 1:35:23 PM To: facebook/jest @.> Cc: Mark Wiemer @.>; Manual @.> Subject: Re: [facebook/jest] What is the official way to run jest programmatically? (#5048)
So apparently it is still a no-no, am I wrong?
— Reply to this email directly, view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ffacebook%2Fjest%2Fissues%2F5048%23issuecomment-1024990606&data=04%7C01%7C%7C4c0cf4818cd643986ef108d9e36f4251%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637790889264846648%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=5Wymg3Zl4clPoKBs59y%2BVErkqy4kqwvwCU69ODtfgKY%3D&reserved=0, or unsubscribehttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAB3YOEARKS45TCMENNCJIOTUYRMRXANCNFSM4EHUJAFQ&data=04%7C01%7C%7C4c0cf4818cd643986ef108d9e36f4251%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637790889264846648%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=%2FMYVq7aqy8vrO8FzYhNd8fp3IJW7ykKehgrxazhTYy0%3D&reserved=0. Triage notifications on the go with GitHub Mobile for iOShttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fapps.apple.com%2Fapp%2Fapple-store%2Fid1477376905%3Fct%3Dnotification-email%26mt%3D8%26pt%3D524675&data=04%7C01%7C%7C4c0cf4818cd643986ef108d9e36f4251%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637790889264846648%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=1sUQ9DG%2FMyW6Yl7o8R5aK1SLjWMerMT2z7tj55ReCj8%3D&reserved=0 or Androidhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fplay.google.com%2Fstore%2Fapps%2Fdetails%3Fid%3Dcom.github.android%26referrer%3Dutm_campaign%253Dnotification-email%2526utm_medium%253Demail%2526utm_source%253Dgithub&data=04%7C01%7C%7C4c0cf4818cd643986ef108d9e36f4251%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637790889264846648%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=moocmCh4kzhx6C4lSGbhcFPhQf%2BvQ%2FtFVNN1NYD0PF8%3D&reserved=0. You are receiving this because you are subscribed to this thread.Message ID: @.***>
Just to support this feature 👍
FWIW Create React App is depending on this implicit API: https://github.com/facebook/create-react-app/blob/3880ba6cfd98d9f2843217fd9061e385274b452f/packages/react-scripts/scripts/test.js#L129
Is jest team(?) still working on this? It seems to me that the official way to run jest programmtically still has not come out yet. Here I am just adding use case to help anyone who is working on this.
my use case: I need to run jest programmatically inside a Serverless AWS lambda function. Some APIs with separate DB are deployed to the Serverless lambda functions. My separate jest test files will be called by one of the lambda function which is not open to public, is created just for this test purpose, and will be invoked only one time in CD(continuous deployment) process.
I am just calling the jest runCLI function to do that for now. If any updates come out, I will follow.
Thank you
@tachyon83 PR https://github.com/jestjs/jest/pull/14062 for this was opened in April 2023 and conversation slowed until halting in late June. It's worth following that PR as well for updates, but I'm sure this issue will be updated as well. Otherwise I'm not optimistic for any fix within 6 months--someone would have to take initiative and that's only happened a couple times in the 5+ years this issue has been open.
I'm particularly interested in an interface that would let met configure a jest instance and run tests multiple times, and cancel on an abort signal. Something like
const jest = new Jest(options);
const signal = AbortSignal.timeout(60_000);
for (await (const _ of setInterval(1_000, { signal })) {
jest.run({ signal })
}
My question is how to run jest programmatically. There are some examples on the internet: https://stackoverflow.com/a/30562836/1652273 https://stackoverflow.com/a/33669530/1652273 https://github.com/facebook/jest/issues/3848
All of them reference requiring
jest
orjest-cli
and callingrunCLI()
, but it does not seem to be documented anywhere (I haven't found anything in the jest docs nor is there any documentation for the jest-cli package).Is this the official supported way? Thanks.