Skip to content

Commit a3d57fe

Browse files
committed
Added 'itonly' command option to support using Mocha's it.only() feature
1 parent 770a72b commit a3d57fe

3 files changed

Lines changed: 16 additions & 6 deletions

File tree

Jakefile.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
var strict = !process.env.loose;
1616
if (strict) console.log("For more forgiving test settings, use 'loose=true'");
1717

18+
var itonly = process.env.itonly;
19+
1820
//*** DIRECTORIES
1921

2022
directory(paths.tempTestfileDir);
@@ -102,7 +104,7 @@
102104
configFile: paths.karmaConfig,
103105
browsers: testedBrowsers(),
104106
strict: strict,
105-
clientArgs: [ "--grep=JS:" ]
107+
clientArgs: testSubsetArgs("JS")
106108
}, complete, fail);
107109
});
108110

@@ -112,10 +114,18 @@
112114
configFile: paths.karmaConfig,
113115
browsers: testedBrowsers(),
114116
strict: strict,
115-
clientArgs: [ "--grep=CSS:" ]
117+
clientArgs: testSubsetArgs("CSS")
116118
}, complete, fail);
117119
});
118120

121+
function testSubsetArgs(tag) {
122+
// We use Mocha's "grep" feature as a poor-man's substitute for proper test tagging and subsetting
123+
// (which Mocha doesn't have at the time of this writing). However, Mocha's grep option disables
124+
// Mocha's "it.only()" feature. So we don't use grep if the "itonly" option is set on the command
125+
// line.
126+
return itonly ? [] : [ "--grep=" + tag + ":" ];
127+
}
128+
119129
desc("End-to-end smoke tests");
120130
task("smoketest", [ "build" ], function() {
121131
console.log("Smoke testing app: ");

readme.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ To build and test this episode:
7474

7575
You can also run `./jake.sh quick loose=true` for a faster but less thorough set of tests.
7676

77+
If you want to use Mocha's `it.only()` feature to run just one test, pass `itonly=true` as well.
78+
7779
*Note:* The master branch is not guaranteed to build successfully. For a known-good build (tested on Mac and Windows, and assumed to work on Linux), use the integration branch. To change branches, follow the steps under "Running old episodes" (above), but replace `episodeXX` with `integration` (for the known-good integration branch) or `master` (for the latest code).
7880

7981

todo.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,9 @@ User Stories to finish current MMF:
2929
- release
3030

3131
Engineering Tasks:
32-
* Run server code out of generated/dist as well (fix hardcoded path in weewikipaint.js)
33-
- Restore 'it.only()' functionality of client test build (conflicts with grep-based test subsetting)
32+
* Restore 'it.only()' functionality of client test build (conflicts with grep-based test subsetting)
3433
- Is there a better of handling cross-directory requires (e.g., `require("../shared/_assert.js")` broke)?
3534
- Where do we want our vendor files to live?
3635
- Move hard-coded paths in Jakefile.js to paths.js?
3736

38-
To Do on current task:
39-
- Rename weewikipaint.js --> run.js?
37+
To Do on current task:

0 commit comments

Comments
 (0)