test-forbidden-regex
v1.1.0
Published
Test helper for testing forbidden regex
Downloads
213
Maintainers
Readme
Strict Folder Structure
with test-forbidden-regex
Why?
Often you wish to follow some strict folder structure.
This is the test helper test-forbidden-regex, which helps you follow strict folder structure
Usage (with Jest):
import {
noImportsInFolder,
relativeImportStartedFromTwoDots,
} from 'test-forbidden-regex';
describe('strict folder structure', () => {
it(
'@material-ui not allowed inside src/components folder',
noImportsInFolder(`components`, [
// you can use RegExp here
relativeImportStartedFromTwoDots,
`@material-ui`,
]),
);
});
This will throw an error, if any file inside src/components
folder will have relative import or import from '@material-ui' library
For example:
such strings will throw an error, if test-forbidden-regex will meet them inside src/components
folder`:
// 1. relativeImportStartedFromTwoDots
import OtherCompoenent from '../components/OtherComponents';
// 2. @material-ui
import { Grid } from '@material-ui/core';
Instalation
npm
npm i test-forbidden-regex -D
yarn
yarn add test-forbidden-regex -D