Skip to content

Commit

Permalink
fix(testing): add general code tests, lost console methods (#351)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdcabrera committed Jul 30, 2020
1 parent 22f3821 commit 8d444ae
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
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');
});
});

0 comments on commit 8d444ae

Please sign in to comment.