MCPcopy Create free account
hub / github.com/plotly/plotly.js / assertJasmineSuites

Function assertJasmineSuites

tasks/test_syntax.js:32–89  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

30
31// check for for focus and exclude jasmine blocks
32function assertJasmineSuites() {
33 var BLACK_LIST = ['fdescribe', 'fit', 'xdescribe', 'xit'];
34 var TAGS = ['noCI', 'noCIdep', 'gl', 'flaky'];
35 var IT_ONLY_TAGS = ['gl', 'flaky'];
36 var logs = [];
37
38 var addTagPrefix = function(t) { return '@' + t; };
39
40 glob(combineGlobs([testGlob, bundleTestGlob])).then((files) => {
41 files.forEach(function(file) {
42 var code = fs.readFileSync(file, 'utf-8');
43 var bn = path.basename(file);
44
45 falafel(code, { ecmaVersion: 'latest', locations: true }, function(node) {
46 var lineInfo = '[line ' + node.loc.start.line + '] :';
47
48 if(node.type === 'Identifier' && BLACK_LIST.indexOf(node.name) !== -1) {
49 logs.push([
50 bn, lineInfo,
51 'contains either a *fdescribe*, *fit*,',
52 '*xdescribe* or *xit* block.'
53 ].join(' '));
54 }
55
56 if(isJasmineTestIt(node)) {
57 if(hasJasmineTestTag(node)) {
58 if(TAGS.every(function(t) { return !hasJasmineTestTag(node, t); })) {
59 logs.push([
60 bn, lineInfo,
61 'contains an unrecognized tag,',
62 'not one of: ' + TAGS.map(addTagPrefix).join(', ')
63 ].join(' '));
64 }
65 }
66
67 if(hasJasmineTestTag(node, 'gl') && hasJasmineTestTag(node, 'flaky')) {
68 logs.push([
69 bn, lineInfo,
70 'contains a @gl tag AND a @flaky tag, which is not allowed'
71 ].join(' '));
72 }
73 }
74
75 IT_ONLY_TAGS.forEach(function(t) {
76 if(isJasmineTestDescribe(node, t)) {
77 logs.push([
78 bn, lineInfo,
79 'contains a', addTagPrefix(t), 'tag is a *describe* block,',
80 addTagPrefix(t), 'tags are only allowed in jasmine *it* blocks.'
81 ].join(' '));
82 }
83 });
84 });
85 });
86
87 log('no jasmine suites focus/exclude blocks or wrong tag patterns', logs);
88 });
89}

Callers 1

test_syntax.jsFile · 0.85

Calls 4

globFunction · 0.85
combineGlobsFunction · 0.85
addTagPrefixFunction · 0.85
logFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…