Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ebdb86e

Browse files
committed
Merge pull request plotly#139 from plotly/jshint-jasmine
Add syntax test for jasmine test files
2 parents 81b9f79 + d284366 commit ebdb86e

File tree

4 files changed

+38
-0
lines changed

4 files changed

+38
-0
lines changed

circle.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ test:
2121
override:
2222
- sudo lxc-attach -n "$(docker inspect --format '{{.Id}}' mytestbed)" -- bash -c "cd /var/www/streambed/image_server/plotly.js && node test/image/compare_pixels_test.js"
2323
- npm run citest-jasmine
24+
- npm run test-syntax

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"test-jasmine": "karma start test/jasmine/karma.conf.js",
3333
"citest-jasmine": "karma start test/jasmine/karma.ciconf.js",
3434
"test-image": "./tasks/test_image.sh",
35+
"test-syntax": "node test/syntax_test.js",
3536
"test": "npm run test-jasmine && npm test-image",
3637
"start-test_dashboard": "node devtools/test_dashboard/server.js",
3738
"start-image_viewer": "node devtools/image_viewer/server.js",
@@ -83,6 +84,7 @@
8384
"browserify": "^12.0.1",
8485
"browserify-transform-tools": "^1.5.0",
8586
"ecstatic": "^1.2.0",
87+
"glob": "^6.0.1",
8688
"jasmine-core": "^2.3.4",
8789
"jshint": "^2.8.0",
8890
"karma": "^0.13.15",

tasks/util/constants.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ module.exports = {
4242
pathToTestImagesDiff: path.join(pathToBuild, 'test_images_diff/'),
4343
pathToTestImagesDiffList: path.join(pathToBuild, 'list_of_incorrect_images.txt'),
4444

45+
pathToJasmineTests: path.join(pathToRoot, 'test/jasmine/tests'),
46+
4547
uglifyOptions: {
4648
fromString: true,
4749
mangle: true,

test/syntax_test.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
var path = require('path');
2+
var fs = require('fs');
3+
4+
var jshint = require('jshint').JSHINT;
5+
var glob = require('glob');
6+
7+
var constants = require('../tasks/util/constants');
8+
9+
var focusGlobals = ['fdescribe', 'fit'];
10+
var logs = [];
11+
12+
13+
glob(path.join(constants.pathToJasmineTests, '**/*.js'), function(err, files) {
14+
files.forEach(function(file) {
15+
var code = fs.readFileSync(file, 'utf-8');
16+
17+
jshint(code);
18+
19+
var impliedGlobals = jshint.data().implieds;
20+
21+
impliedGlobals.forEach(function(obj) {
22+
if(focusGlobals.indexOf(obj.name) !== -1) {
23+
logs.push([
24+
path.basename(file),
25+
'[line ' + obj.line + '] :',
26+
'contains either a *fdescribe* or a *fit* block.'
27+
].join(' '));
28+
}
29+
});
30+
});
31+
32+
if(logs.length) throw new Error(logs.join('\n'));
33+
});

0 commit comments

Comments
 (0)