Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(testing): add general code tests, lost console methods #351

Merged
merged 1 commit into from
Jul 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions tests/__snapshots__/code.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`General code checks should only have specific console.[warn|log|info|error] methods: console methods 1`] = `
Array [
"redux/common/reduxHelpers.js:167: console.error(\`Error: Property \${prop} does not exist within the passed state.\`, state);",
"redux/common/reduxHelpers.js:171: console.warn(\`Warning: Property \${prop} does not exist within the passed initialState.\`, initialState);",
"setupTests.js:70: console.error = (message, ...args) => {",
]
`;
18 changes: 18 additions & 0 deletions tests/code.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const { execSync } = require('child_process');

describe('General code checks', () => {
const srcDir = 'src';

it('should only have specific console.[warn|log|info|error] methods', () => {
const output = execSync(
`echo "$(cd ./${srcDir} && git grep -n -E "(console.warn|console.log|console.info|console.error)")"`
);

expect(
output
.toString()
.trim()
.split(/[\n\r]/g)
).toMatchSnapshot('console methods');
});
});