Skip to content

Fixing broken tests

Abel Fernández edited this page May 19, 2020 · 2 revisions

Prerequisite

First of all, you must make sure that your project is correctly built.

Storybook

The first thing that may fail is the snapshot of the storybook stories, this is because it must be updated if you make any change to the layout. In order to do so, run yarn test -u from the valdueza-storybook package directory.

DOM and E2E tests

The key to bugfixing these is narrowing the problem. The describe and it blocks can be skipped by appending ".skip" (describe.skip(..., it.skip(...), or executed without the others in the same block by appending ".only" (describe.only(..., it.only(...).

There are also withChainsDescribe blocks that only run when the environment variable CHAINS_ENABLED is set to 1: export CHAINS_ENABLED=1. The .skip and .only functions can also be used with this block.

This lets you run only the tests that you want to fix, so you may enable one at a time and move to the next when you fix it.

Narrowing with yarn commands

You may also further narrow your testing scope by running yarn test-dom or yarn test-e2e instead of yarn test. What is more, you can do yarn test-single <test-file> in order to check a single file. This, combined with the .skip and .only functions, lets you pinpoint the issues more easily.