-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Table for test.each cannot be loaded in beforeAll step #6888
Comments
I had a similar issue to this in the original jest-each (mattphillips/jest-each#6). We would need Jest to run the
|
We're not gonna run any hooks before collecting tests, we don't wanna "execute" a file multiple times.
|
For people finding this googling how to use let foo: string;
let bar: number;
beforeAll(async () => {
foo = await asyncFunctionA();
bar = await asyncFunctionB();
}, 10000);
afterAll(async () => {
await tearDown();
});
describe("Characteristic", () => {
it.each`
foo | bar | whatever | returnValue
${foo} | ${bar} | ${1} | ${2}
${foo} | ${bar} | ${2} | ${4}
${foo} | ${bar} | ${3} | ${6}
${foo} | ${bar} | ${4} | ${8}
`(
"table works with $foo, $bar and $whatever",
async ({ foo, bar, whatever, returnValue }) => {
expect(yourFunction(foo, bar, whatever)).toBe(returnValue);
}
);
}); |
it seems that describe runs before beforeAll. Sot foo and bar will remain undefined. |
How would one then pull in a sitemap.xml and set all of the endpoints? |
Is there any workaround to run I have to execute async requests inside |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
🐛 Bug Report
Tests don't run if there is a
test.each(table, fn)
wheretable
is a global state which is populated inbeforeAll
. But sincejest
analysis sees it as no tests it doesn't runbeforeAll
either.To Reproduce
Expected behavior
Test should run for all elements loaded into the table after execution of
beforeAll
.The text was updated successfully, but these errors were encountered: