You can never go wrong with Jasmine when doing frontend testing.
- Project with all common usage as running tests
- Blog post series on Jasmine
- Blog migrating from Jasmine to Jest
- AVA: an alternative test runner
Exercises are detailed below or in the Github Discussions
Facebook test runner for React. Stole Mocha's mojo. Syntax is largely identical to Jasmine.
cd react-testing
npm run debug:test
Put a debugger;
and use the Node.js V8 --inspector Manager extension.
See .vscode/launch.json
.
react-testing/src/date-holidays
: Is it time to fix the date-holidays performance issue permanently, TDD style?
See confac
Tag: jest-start
Entrypoint: /backend/src/controllers/tests/
0-config-templates.test.ts
: Mocking the FileSystem (easy)0-user-verify.test.ts
: Mocking the google-auth-library (easy)1-clients.test.ts
: Manual Express Mocking (easy)2-consultants.test.ts
: Switching tomongodb-memory-server
from our poor-manfakeDb
implementation (medium)3-projectsMonth.test.ts
: Mocking Express withsupertest
(medium)4-projectsMonth.test.ts
: Bringing it all together (medium)7-deleteInvoiceController.test.ts
: You're on your own now (hard)8-createInvoiceController.test.ts
: A whole bunch of mocking (hard)9-emailInvoiceController.test.ts
: Buffers, merging, lots of fun (hard)
There are three ways to test React components:
ReactTestUtils: The most barebone API, the other 2 are built on top of this
react-testing-library:
What we will be using.
Enzyme:
The React team no longer recommends the Enzyme library as their primary choice for React testing.
This was a really bad idea.
But it looks pretty cool.
- Showcase: Use this as an entrypoint to their documentation (upper right icon)
- Github Repo
- Simple Sandbox example: really basic.
- Bug: some Wired components crash: Slider, IconButton, Fab, ...
- React Wrappers for Web Components
- React and Web Components
- Chrome Extension
- DOM Queries: See
0.Enquete.test.tsc
- Fire Events: fireEvent.click()
- jest-dom: toBeInTheDocument etc
- shadow-dom-testing-library: An additional package because WebComponents...
Protracter is being deprecated?
- ReactiveForms testing
- Component testing
- Directive testing