Jest: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 40: | Line 40: | ||
=Skipping and Isolating Tests= | =Skipping and Isolating Tests= | ||
Add keyword only to include tests | Add keyword only to include tests |
Revision as of 00:54, 21 May 2020
Naming Test
__tests__/*.js *.spec.js *.test.js
Example Test
Describe is the suite, it is the test
describe("The question list ", ()=> { it ("should display a list of items", ()=> { expect(2+2).toEqual(4); })
it ("should display a list of items", ()=> { expect(2+4).toEqual(6); })
})
Setup and Teardown
This can be done using
BeforeEach BeforeAll
beforeAll(()=>{ console.log("Hello"); });
and
AfterEach AfterAll
afterAll(()=>{ console.log("Hello"); });
Note does not matter what order you write them in.
Skipping and Isolating Tests
Add keyword only to include tests
it.only ("should display a list of items", ()=> { expect(2+2).toEqual(4); })
Add keyword skip to exlude tests
it.skip ("should display a list of items", ()=> { expect(2+2).toEqual(4); })