Table for test.each cannot be loaded in beforeAll step
See original GitHub issue🐛 Bug Report
Tests don’t run if there is a test.each(table, fn)
where table
is a global state which is populated in beforeAll
. But since jest
analysis sees it as no tests it doesn’t run beforeAll
either.
To Reproduce
const tableData = [];
beforeAll(() => {
tableData.push([1]);
});
test.each(tableData, ('%d', (num) => console.log(num)));
Expected behavior
Test should run for all elements loaded into the table after execution of beforeAll
.
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
How to configure the test.each table with variables defined in ...
From the doc Defining Tests says: Tests must be defined synchronously for Jest to be able to collect your tests.
Read more >Setup and Teardown - Jest
By default, the beforeAll and afterAll blocks apply to every test in a file. You can also group tests together using a describe...
Read more >Mocha - the fun, simple, flexible JavaScript test framework
When a test file is loaded, Mocha executes all of its suites and finds–but does not execute–any hooks and tests therein. Top-level hooks,...
Read more >Testing - Spring
The Spring TestContext Framework provides consistent loading of Spring ... A TestContextManager is created for each test class (for example, ...
Read more >Best Practices - Cypress Documentation
Instead, adding the data-cy attribute to the element gives us a targeted selector that's only used for testing. The data-cy attribute will not...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For people finding this googling how to use
jest.each
withbeforeAll
orebeforeEach
. You can still put those before yourdescribe
block:We’re not gonna run any hooks before collecting tests, we don’t wanna “execute” a file multiple times.
jest-each
should probably throw an explicit error if given an empty array