Testing
- The Power of Mocking in Unit Tests
- Unit Test Success using Ports, Adapters, and Simulators | Microsoft Learn
Test Cases
Jest
Jest for Typescript based unit tests.
- supertest - npm
- The only 3 steps you need to mock an API call in Jest - DEV Community
- Mock Functions · Jest
- reactjs -
Property 'mockResolvedValue' does not exist on type '<T = any, R = AxiosResponse<T>>
- Stack Overflow - reactjs - Why am I getting: TypeError: axios.default.get.mockResolvedValue is not a function - Stack Overflow
- Mocking axios in Jest tests with Typescript | C.S. Rhymes
- javascript - Jest mocking: TypeError: axios.get.mockResolvedValue is not a function - Stack Overflow
- javascript - Mock Axios to test .catch() - Stack Overflow
- Mock Functions · Jest
- javascript - How to test the type of a thrown exception in Jest - Stack Overflow
Snapshot Testing
- https://jestjs.io/docs/snapshot-testing
- Ignore snapshots https://stackoverflow.com/questions/58015748/how-ignore-snapshot-generated-by-jest-on-jests-coverage
Single Test Run
Use test.only
function or npm run test -- regex/to/this.test
More info found at https://geshan.com.np/blog/2022/07/jest-run-single-test/
Useful Commands
npm run clear-jest
Jest
ab
sudo yum install httpd-tools
ab -n 100 -c 100 -p testquery.json -T "application/json" -H 'x-api-key: foo' https://testsite/
Testing with curl swapping hostnames
curl -v -H "Host:www.foo.com" "http://123.45.67.89/"
curl -v -H "Hostname: www.foo.com" https://123.45.67.89/test
curl -v --connect-to 123.45.67.89:443 https://www.foo.com/test