Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

JavaScript Testing

17 August 2023 09:36

Why test?
- Code confidence
- Documentation
- Easy refactoring
- Better development
- Team work

See files in javascript-testing-fundamentals-master file

What to test?
- Asking: would it be bad for the app if this code breaks?
Constructors need not be tested individually, they're called in
every other test case.
Test authentication: is the user an admin?
How much code is covered by a test?
Test Coverage - how much code is covered by a test?

Types - AIU
Unit testing - small pieces of code, complex user flows, in
betweens.
Acceptance tests (end-to-end tests) - complex flows.
Integration/functional tests - in between stuff
- Verify the code is working

Mocks/mocking
Replacing imported Permissions class with custom mock
implementation. Though the example is done on the same file,
in the real world it is structured in different files.

Stubs
While mocks replace what was there before, stubs replace a
specific piece of what was there before.

Spies
Verifying a function without altering the outcome, in a less
extensive format, we use spying on libraries to assign methods
in order to spy the associated object.

You might also like