Skip to content

Latest commit

 

History

History
53 lines (38 loc) · 1.2 KB

Testing.md

File metadata and controls

53 lines (38 loc) · 1.2 KB

Testing

All things unit, integration, TDD.


  1. TDD
    1. Integration Tests
  2. Jest

Test Driven Development

1.1 Integration Tests

  • ✘ Using tools like Postman
  • ✓ Writing tests in code

Integration tests should exist within source code.

  • Code can be debugged with a debugger
  • Tests can be more intelligent, making use of full node environment

1.2 Serverless Integration Tests

See ./Serverless.md#integration-tests

Jest

To use jest:

  • ✓ Configure your package.json
    • yarn test:integration will execute files like foo.int-test.ts
    • yarn test will execute unit tests matching only foo.test.ts or foo.spec.ts
{
  "scripts": {
    "build": "tsc",
    "test": "jest", // Runs your tests as configured in jest.config.js
    "test:build": "jest --config '{}'", // Tests your built files, with the default config
    "test:integration": "jest --testMatch '**/*.int-test.*'" // Only hits file like `fancy.int-test.ts`
  }
}
  • ✓ Create a jest.config.js file. This file is automatically detected by jest.
{
  "verbose": true,
  "setupFiles": ["./test/setup.js"]
}