Basic Testing Conventions on my prjects

borysshulyak

Boris Shulyak

Posted on April 13, 2024

Basic Testing Conventions on my prjects

General conventions for tests

Integration Tests

Mocking

The more your tests resemble the way your software is used, the more confidence they can give you.

Style Guide

  • Use mixins/jest or mixins/vitest from @runespoor/eslint-config.
  • The test file should be located in the __tests__/unit or __tests__/integration folder, depending on the tests type. - It will help to run unit and integration test separatly.
  • The tests should be located in the same folder as the component/method/class you are testing.
  • The name of the test file should be the same as the component/method/class you are testing, but with the .test suffix.
  • describe:
    • Do not use nested describe.
    • The message should be the name of the component/method/class your are testing.
    • Example: describe('useEntitiesMap', () => {})
  • it:
    • The message should be started with should word.
    • The message should be in the present tense.
    • Use ` ` quotes for all the technical names (props, args, handlers, hooks, etc.).
    • Example: it('should skip the entity if it does not have an object by the provided `entityDataPath`', () => {})
  • Mocks:
    • The name of the mock function or constant should be started with mock word. (not mocking , not mocked )

Read More

💖 💪 🙅 🚩
borysshulyak
Boris Shulyak

Posted on April 13, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Basic Testing Conventions on my prjects
javascript Basic Testing Conventions on my prjects

April 13, 2024