I get these Flow errors in my test files:
identifier `test`
Could not resolve name
identifier `expect`
Could not resolve name
I've installed the Jest libdef from flow-typed but it doesn't make any difference.
Update: it looks like the Jest libdef created by flow-typed is just a stub. I think the problem is that flow-typed doesn't have a libdef for Jest v0.21.x yet.
In order to run a specific test, you'll need to use the jest command. npm test will not work. To access jest directly on the command line, install it via npm i -g jest-cli or yarn global add jest-cli . Then simply run your specific test with jest bar.
beforeEach(fn) #Runs a function before each of the tests in this file runs. If the function returns a promise, Jest waits for that promise to resolve before running the test. This is often useful if you want to reset some global state that will be used by many tests.
describe breaks your test suite into components. Depending on your test strategy, you might have a describe for each function in your class, each module of your plugin, or each user-facing piece of functionality. You can also nest describes to further subdivide the suite. it is where you perform individual tests.
What's the right way to write Jest tests verified with Flow?
flow-typed
now has all versions of Jest:
https://github.com/flowtype/flow-typed/tree/master/definitions/npm
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With