CLI
Run specific test
- pass a file pattern as the final argument
- this would match
spec/index.spec.js
jest spec/index
- you can also filter tests by test name (not file name)
- this includes the surrounding describe blocks - ex.
jest -t "#describe testName"
jest -t testName
Show console logs
Matchers
Match partial objects, arrays, strings
expect(mockFn).toHaveBeenCalledWith(
expect.objectContaining({
id: 123,
name: expect.stringContaining('sofa'),
model: expect.stringMatching(/A\d{3}/),
colors: expect.arrayContaining(['red', 'blue']),
})
)