DEV Community

Boris Shulyak
Boris Shulyak

Posted on

2

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

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay