Statements | Branches | Functions | Lines |
---|---|---|---|
- rate limit all API requests
- travel recommendation API
- CI
- Front end
- takes source and destination
- takes dates
- checks weather
- checks holdiays
DEBUG=test node --inspect=9229 ./node_modules/jest/bin/jest.js --runInBand --watch --verbose
Without --runInBand
unable to attach debugger to a running process
- to mock node modules (e.g. lodash), place the file in
__mocks__
and the package will automatically get mocked. There is no need to explicatly calljest.mock(module_name)
- to mock core node modules (e.g. fs, path etc.), similarly place the file and explicitly call
jest.mock('module_name')
- if
automock
is set totrue
, then you dont need to explicitly calljest.mock(module_name)
jest.unmock(module_name)
is available in case you want the actually implementation but have mocked implementation due toautomock
being present.jest.getMockFromModule(module_name)
cane be used to automatically mock everything in the module. This is useful when you want to override one off thing in the module, but dont want to manually mock everything. In this case just use the autogenerated mocks and modify or add whatever is needed and then export that new thing.jest.requireActual(module_name)
gives the actual implementation of the module- the
__mocks__
directory goes in all directories next to the source code they mock
- toBe
- toEqual
- toMatch
my last test always fail when i run tests consistently. so its reproducible if i put a breakpoint in this test, it works if i run this test alone, it works it only fails when i run all test and i am not debugging it what gives? turns out its the rate-limiter module i had built. the 429 error code on the response gave it all away.
jest.setTimeout(100)
otherwise default is 5 seconds of waiting for each test to call done.