Skip to content

itenium-be/Frontend-UnitTesting

Repository files navigation

Frontend UnitTesting

Jasmine

You can never go wrong with Jasmine when doing frontend testing.

Exercises are detailed below or in the Github Discussions

Jest

Facebook test runner for React. Stole Mocha's mojo. Syntax is largely identical to Jasmine.

Debugging

Chrome

cd react-testing
npm run debug:test

Put a debugger; and use the Node.js V8 --inspector Manager extension.

Visual Studio Code

VS Code Extension

See .vscode/launch.json.

Jest Exercise

  • react-testing/src/date-holidays: Is it time to fix the date-holidays performance issue permanently, TDD style?

Express Exercises

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 to mongodb-memory-server from our poor-man fakeDb implementation (medium)
  • 3-projectsMonth.test.ts: Mocking Express with supertest (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)

React

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.

Wired Elements

This was a really bad idea.
But it looks pretty cool.

The DOM

Angular

Protracter is being deprecated?

  • ReactiveForms testing
  • Component testing
  • Directive testing

https://testing-angular.com/

About

Frontend UnitTesting: Jasmine, Jest, React & Angular

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published