Javascript Testing

run jest or npm test to run the test

Updating -u automatically regenerate snapshots for all failing snapshot tests. Useful if you made a change that caused many snapshots tests to fail

Spec files this is where you actually configure the tests

You can search in vscode using \*.spec*

Inside the spec files you can include different tests with changed props, states, and jscontext.

**JSCONTEXT contains ats_user and not ats_users

ats_user is the current user

There’s also the little object wrapper that gets applied to all of the tests, where yuka2: true is

Creating a snapshot running npm test will create a snapshot for the new tests you wrote. It shows up on the git diff

**Mocking Partial parts of a module

Mocking Partials

You can’t define a mock for a function more than once

jest.mock(“react-router-dom”, () ({
…jest.requireActual(“react-router-dom”),
useMatch: () ({
params: {
commitment: “discussion”,
},
pathname: “/ats/submit-order/discussion/“,
pathnameBase: “/ats/submit-order/discussion”,
pattern: {
path: “/ats/submit-order/:commitment/“,
caseSensitive: false,
end: true,
},
}),

**Also using react testing library **