Skip to content

Commit c8b5ad2

Browse files
committed
Merge pull request honestbleeps#2588 from erikdesjardins/gulp-qunit
Run QUnit tests in Gulp
2 parents fee58b3 + 671a49f commit c8b5ad2

File tree

4 files changed

+38
-14
lines changed

4 files changed

+38
-14
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ Sass (`.scss`) files in `lib/` will be compiled with [Sass](http://sass-lang.com
116116

117117
**`gulp <tasks> -b chrome -b firefox`** can be used with any of the above commands to specify individual browsers (chrome, firefox, safari), instead of performing the task(s) for all of them.
118118

119-
**`gulp travis`** will verify the code style (and point out any errors) of all `.js` files in `lib/` (except `lib/vendor/`) using [ESLint](http://eslint.org/), as well as all `.scss` files with [scss-lint](https://github.com/brigade/scss-lint). We recommend that you run this before opening a pull request. (This is used by Travis CI to automatically test pull requests.)
119+
**`gulp travis`** will verify the code style (and point out any errors) of all `.js` files in `lib/` (except `lib/vendor/`) using [ESLint](http://eslint.org/), as well as all `.scss` files with [scss-lint](https://github.com/brigade/scss-lint). It will also run QUnit tests (in `tests/qunit`). We recommend that you run this before opening a pull request. (This is used by Travis CI to automatically test pull requests.)
120120

121121
Note: You will need to install [Ruby](https://www.ruby-lang.org/) and run `gem install scss_lint` before using `gulp travis`.
122122

gulpfile.babel.js

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import plumber from 'gulp-plumber';
1414
import sourcemaps from 'gulp-sourcemaps';
1515
import eslint from 'gulp-eslint';
1616
import scsslint from 'gulp-scss-lint';
17+
import qunit from 'gulp-qunit';
1718
import through from 'through-gulp';
1819

1920
const options = require('minimist')(process.argv.slice(2));
@@ -94,6 +95,15 @@ const browserConf = {
9495
root: 'node',
9596
baseSources: 'lib'
9697
}
98+
},
99+
qunit: {
100+
sources: [
101+
{ cwd: 'tests/qunit/**', src: '*.*' }
102+
],
103+
dests: {
104+
root: 'qunit',
105+
baseSources: '/'
106+
}
97107
}
98108
};
99109

@@ -184,12 +194,14 @@ gulp.task('copy-browser', () =>
184194

185195
gulp.task('manifests', () =>
186196
merge(
187-
browsers.map(browser =>
188-
gulp.src(browserConf[browser].manifest || ['*', '!*'])
189-
.pipe(cache('manifests'))
190-
.pipe(through.map(file => populateManifest(browser, file)))
191-
.pipe(dest(getBuildDir(browser)))
192-
)
197+
browsers
198+
.filter(browser => browserConf[browser].manifest)
199+
.map(browser =>
200+
gulp.src(browserConf[browser].manifest)
201+
.pipe(cache('manifests'))
202+
.pipe(through.map(file => populateManifest(browser, file)))
203+
.pipe(dest(getBuildDir(browser)))
204+
)
193205
)
194206
);
195207

@@ -219,13 +231,19 @@ function populateManifest(browser, file) {
219231
// Add new modules to browser manifests
220232
gulp.task('add-module', () =>
221233
merge(
222-
browsers.map(browser => addModuleToManifest(browserConf[browser].filesList || browserConf[browser].manifest))
234+
browsers
235+
.map(browser => browserConf[browser].filesList || browserConf[browser].manifest)
236+
.filter(manifest => manifest)
237+
.map(manifest => addModuleToManifest(manifest))
223238
)
224239
);
225240

226241
gulp.task('add-host', () =>
227242
merge(
228-
browsers.map(browser => addHostToManifest(browserConf[browser].filesList || browserConf[browser].manifest))
243+
browsers
244+
.map(browser => browserConf[browser].filesList || browserConf[browser].manifest)
245+
.filter(manifest => manifest)
246+
.map(manifest => addHostToManifest(manifest))
229247
)
230248
);
231249

@@ -267,7 +285,7 @@ gulp.task('zip', () => {
267285
);
268286
});
269287

270-
gulp.task('travis', ['eslint', 'scsslint']);
288+
gulp.task('travis', ['eslint', 'scsslint', 'qunit']);
271289

272290
gulp.task('eslint', () =>
273291
src(baseConf.sources.babel)
@@ -281,3 +299,9 @@ gulp.task('scsslint', () =>
281299
.pipe(scsslint({ maxBuffer: 1024 * 1024 }))
282300
.pipe(scsslint.failReporter())
283301
);
302+
303+
// todo: when Gulp 4 is released, only build qunit
304+
gulp.task('qunit', ['build'], () =>
305+
gulp.src('dist/qunit/tests.html')
306+
.pipe(qunit())
307+
);

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"gulp-cached": "^1.1.0",
2323
"gulp-eslint": "^1.1.0",
2424
"gulp-plumber": "^1.0.0",
25+
"gulp-qunit": "^1.3.0",
2526
"gulp-replace": "^0.5.4",
2627
"gulp-sass": "^2.1.1",
2728
"gulp-scss-lint": "^0.3.8",

tests/qunit/tests.html

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@
77
</head>
88
<body>
99
<div id="qunit"></div>
10-
<div id="qunit-fixture"></div>
10+
<div id="qunit-fixture"></div>
1111

12-
<script src="../../lib/vendor/jquery-1.11.3.min.js"></script>
13-
<script src="../../lib/reddit_enhancement_suite.user.js"></script>
14-
<script src="../../lib/core/utils.js"></script>
12+
<script src="vendor/jquery-1.11.3.min.js"></script>
13+
<script src="core/utils.js"></script>
1514
<script src="../../node_modules/qunitjs/qunit/qunit.js"></script>
1615

1716
<script src="test-escapeHTML.js"></script>

0 commit comments

Comments
 (0)