Skip to content

Commit f3d1e3f

Browse files
add jasmine skip test blacklist meta test
1 parent 7df39f1 commit f3d1e3f

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"eslint-plugin-import": "^2.8.0",
5050
"eslint-plugin-react": "^7.4.0",
5151
"gl": "^4.0.4",
52+
"glob": "^7.1.2",
5253
"jest": "^21.2.1",
5354
"mkdirp": "^0.5.1",
5455
"node-sass": "^4.7.1",

src/__tests__/syntax-test.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// check for for focus and exclude jasmine blocks
2+
import fs from 'fs';
3+
import glob from 'glob';
4+
5+
const BLACK_LIST = ['fdescribe', 'fit', 'xdescribe', 'xit'];
6+
const REGEXS = BLACK_LIST.map(token => new RegExp(`^\\s*${token}\\(.*`));
7+
8+
describe('Syntax and test validation', () => {
9+
describe(`ensures ${BLACK_LIST} is not present in tests`, () => {
10+
const files = glob.sync('**/__tests__/*.js');
11+
files.forEach(file =>
12+
it(`checks ${file} for test checks`, () => {
13+
const code = fs.readFileSync(file, {encoding: 'utf-8'});
14+
code.split('\n').forEach(line => {
15+
expect(REGEXS.some(re => re.test(line))).toBe(false);
16+
});
17+
})
18+
);
19+
});
20+
});

0 commit comments

Comments
 (0)