6.0.5 • Published 3 years ago

@bbc/psammead-test-helpers v6.0.5

Weekly downloads
1,172
License
Apache-2.0
Repository
github
Last release
3 years ago

psammead-test-helpers - Known Vulnerabilities Dependency Status peerDependencies Status GitHub license npm version PRs Welcome

This package provides a collection of helper methods for implementing Jest snapshot tests, required by many Psammead components.

Exported Functions

NameArgumentsDescription
shouldMatchSnapshottitle, componentRenders the component using @testing-library/react, converts it to JSON and asserts that it matches the given snapshot, which will be saved in the __snapshots__ directory. The first argument title is the title for the test.
matchSnapshotAsynccomponentRenders the component using @testing-library/react, converts it to JSON and asserts that it matches the given snapshot, which will be saved in the __snapshots__ directory. Unlike shouldMatchSnapshot, it does not create a test, so can be used within any it(...) test.
isNulltitle, componentRenders the component using @testing-library/react, converts it to JSON and asserts that it is null. The first argument title is the title for the test.
testUtilityPackagesactualExports, expectedExports, utilityNameValidates an imported utility package's exported values against an object of key-value pairs in the form { name_of_export: 'type of export' }, e.g. { shouldMatchSnapshot: 'function' }.
setWindowValuekey, valueAllows you to set variables on the window (eg. location) that are normally not writable
resetWindowValuekey, valueAllows you to reset the WindowValues that are previously overwritten by the setWindowValue function
suppressPropWarningswarningsSuppresses predicted prop warnings during tests.

Installation

npm install react react-dom @bbc/psammead-test-helpers --save-dev

Usage

import { shouldMatchSnapshot } from '@bbc/psammead-test-helpers';

shouldMatchSnapshot('should render correctly', <h1>Hello World</h1>);

Roadmap

Contributing

When adding a new export to this utility package the export tests also need to be updated and the export should be adding to the README. When removing an exisiting export from this utility package the export tests need to be updated, the export should be removed from the README and the package version requires a major change (EG: 1.2.1 -> 2.0.0) as this would be considered a breaking change due to functionality being removed.

Psammead is completely open source. We are grateful for any contributions, whether they be new components, bug fixes or general improvements. Please see our primary contributing guide which can be found at the root of the Psammead respository.

Code of Conduct

We welcome feedback and help on this work. By participating in this project, you agree to abide by the code of conduct. Please take a moment to read it.

License

Psammead is Apache 2.0 licensed.

6.0.5

3 years ago

6.0.4

3 years ago

6.0.3

3 years ago

6.0.2

3 years ago

6.0.1

3 years ago

6.0.0

3 years ago

5.0.2

3 years ago

5.0.1

4 years ago

5.0.0

4 years ago

4.0.0

4 years ago

3.1.5

4 years ago

3.1.4

4 years ago

3.1.3

4 years ago

3.1.2

5 years ago

3.1.1

5 years ago

3.1.0

5 years ago

3.0.2

5 years ago

3.0.1

5 years ago

3.0.0

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.3.4

5 years ago

0.3.3

5 years ago

0.3.2

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.1

5 years ago

0.2.0-alpha.0

5 years ago

0.1.0

5 years ago