diff --git a/tests/__snapshots__/code.test.js.snap b/tests/__snapshots__/code.test.js.snap new file mode 100644 index 000000000..75b7ff9e8 --- /dev/null +++ b/tests/__snapshots__/code.test.js.snap @@ -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) => {", +] +`; diff --git a/tests/code.test.js b/tests/code.test.js new file mode 100644 index 000000000..9e8ab7fcf --- /dev/null +++ b/tests/code.test.js @@ -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'); + }); +});