In your test files, EasyTest puts each of these methods and objects into the global environment. You don't have to require or import anything to use them. However, if you prefer explicit imports, you can do import:
beforeAll
- runs before all tests in a suite.afterAll
- runs after all tests in a suite.beforeEach
- runs before each test in a suite.afterEach
- runs after each test in a suite.describe
- creates a test suite.expect
- creates an expectation.test
- creates a test.it
- creates a test.beforeAll
- Runs a function before any of the tests in this file run.
If the function returns a promise or is a generator, EasyTest waits for that promise to resolve before running tests.
This is often useful if you want to set up some global state that will be used by many tests.
If beforeAll
is inside a describe
block, it runs at the beginning of the describe
block.
afterAll
Runs a function after all the tests in this file have completed.
If the function returns a promise or is a generator, EasyTest waits for that promise to resolve before continuing.
This is often useful if you want to clean up some global setup state that is shared across tests.
If afterAll
is inside a describe
block, it runs at the end of the describe
block.
Runs a function before each of the tests in this file runs. If the function returns a promise or is a generator, EasyTest waits for that promise to resolve before running the test.
This is often useful if you want to set up some state before each test runs.
If beforeEach
is inside a describe
block, it runs for each test in the describe
block.
Runs a function after each one of the tests in this file completes. If the function returns a promise or is a generator, EasyTest waits for that promise to resolve before continuing.
This is often useful if you want to clean up some state after each test runs.
describe(name, fn)
creates a block that groups together several related tests.
This isn't required - you can write the test blocks directly at the top level with test()
function.
But this can be handy if you prefer your tests to be organized into groups.
This isn't required - you can write the test blocks directly at the top level with test()
function.
Create test inside describe
block.
expect(value)
creates an expectation for a value.
The expect
function is used every time you want to test a value.
The expect
returns an expectation
object with matchers
.
You can use multiple expect calls in a single test