Comments (2)
Hey @dainchatel I suspect the issue is because when each
is being evaluated the products
array is still undefined
.
I've knocked up a quick example in a Jest repl here
The example just uses log statements instead of each
describe('test suite', () => {
let products
beforeAll(() => {
products = [['def', '321'], ['abc', '123']]
})
describe('in here now', () => {
console.log('No products', products)
test('this should log the products', () => {
console.log('Products:', products);
})
})
})
As you will see when you run the repl the outer log with be undefined
with the one inside of the test being the actual array. This is because Jest is internally preventing the execution of the test callback function until the beforeAll
is run.
It appears that the inner describe
callback is evaluated immediately but not the nested test
s which means the console.log
or each
function is also evaluated immediately so we are unable to wait on the global setup hooks (beforeAll
etc).
I'm not sure there is a way around this unfortunately.
It might be worth asking a question in a core Jest channel to see if a describe
block should wait for the beforeAll
to finish before being executed?
from jest-each.
thanks, @mattphillips! I really appreciate your answer. I came to the same conclusion, and may go see what the main jest channel has to say about whether nested describe blocks should wait for a beforeAll. But for deadline's sake, just ended up loading my products synchronously. Since it's not an issue with jest-each I will close. Thanks again-
from jest-each.
Related Issues (5)
- Complex datasets HOT 2
- Doesn't show test name on fail HOT 2
- Add typing support HOT 9
- Support non-nested arrays? HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jest-each.