Skip to content

Commit

Permalink
Added plugin testing
Browse files Browse the repository at this point in the history
  • Loading branch information
crutchcorn committed May 6, 2020
1 parent 653494c commit c9b81c6
Show file tree
Hide file tree
Showing 10 changed files with 384 additions and 16 deletions.
3 changes: 3 additions & 0 deletions config/setupAfterEnv.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { toMatchFile } from 'jest-file-snapshot';

expect.extend({ toMatchFile });
13 changes: 8 additions & 5 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ module.exports = {
// setupFiles: [],

// A list of paths to modules that run some code to configure or set up the testing framework before each test
// setupFilesAfterEnv: [],
setupFilesAfterEnv: ['./config/setupAfterEnv.js'],

// A list of paths to snapshot serializer modules Jest should use for snapshot testing
// snapshotSerializers: [],
Expand All @@ -147,9 +147,10 @@ module.exports = {
// ],

// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
// testPathIgnorePatterns: [
// "\\\\node_modules\\\\"
// ],
testPathIgnorePatterns: [
"\\\\node_modules\\\\",
"\\\\__fixtures__\\\\"
],

// The regexp pattern or array of patterns that Jest uses to detect test files
// testRegex: [],
Expand Down Expand Up @@ -181,7 +182,9 @@ module.exports = {
// verbose: undefined,

// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
// watchPathIgnorePatterns: [],
"watchPathIgnorePatterns": [
"__fixtures__\\/[^/]+\\/(output|error)\\.js"
]

// Whether to use watchman for file crawling
// watchman: true,
Expand Down
143 changes: 143 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@
"@babel/parser": "^7.9.6",
"@babel/traverse": "^7.9.6",
"babel-plugin-tester": "^9.0.1",
"jest": "^25.5.4",
"babel-test": "^0.2.3",
"eslint": "^6.8.0",
"eslint-plugin-evelyn": "^2.0.0",
"eslint-plugin-mocha": "^5.3.0",
"eslint-plugin-node": "^9.2.0",
"eslint-plugin-unicorn": "^9.1.1",
"eslint-plugin-evelyn": "^2.0.0"
"jest": "^25.5.4",
"jest-file-snapshot": "^0.3.8"
},
"dependencies": {
"@babel/preset-env": "^7.4.5"
Expand Down
20 changes: 20 additions & 0 deletions plugin/__tests__/__fixtures__/basic/code.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const global = {prop: "test"};

$shouldNotMutate(['foo']);
const foo = (foo) => {
foo.prop = "pie";
};

$shouldNotMutate(['foo']);
function bar(foo) {
foo.prop = 'Test';
}

/**
* This does not currently work
*/
$shouldNotMutate(['foo']);
const pizza = foo => console.log(foo);

foo(global);
bar(global);
Loading

0 comments on commit c9b81c6

Please sign in to comment.