Commit fd99644f authored by Robert Knight's avatar Robert Knight

Add some clarifying comments

Add comments to clarify a few things about the way the tests are built
and run.
parent 8c92b413
...@@ -276,6 +276,8 @@ gulp.task( ...@@ -276,6 +276,8 @@ gulp.task(
async function buildAndRunTests() { async function buildAndRunTests() {
const { grep, singleRun } = karmaOptions; const { grep, singleRun } = karmaOptions;
// Generate an entry file for the test bundle. This imports all the test
// modules, filtered by the pattern specified by the `--grep` CLI option.
const testFiles = [ const testFiles = [
'src/sidebar/test/bootstrap.js', 'src/sidebar/test/bootstrap.js',
...glob ...glob
...@@ -290,14 +292,16 @@ async function buildAndRunTests() { ...@@ -290,14 +292,16 @@ async function buildAndRunTests() {
mkdirSync('build/scripts', { recursive: true }); mkdirSync('build/scripts', { recursive: true });
writeFileSync('build/scripts/test-inputs.js', testSource); writeFileSync('build/scripts/test-inputs.js', testSource);
// Build the test bundle.
log(`Building test bundle... (${testFiles.length} files)`); log(`Building test bundle... (${testFiles.length} files)`);
if (singleRun) { if (singleRun) {
await buildJS('./rollup-tests.config.js'); await buildJS('./rollup-tests.config.js');
} else { } else {
await watchJS('./rollup-tests.config.js'); await watchJS('./rollup-tests.config.js');
} }
log('Starting Karma...');
// Run the tests.
log('Starting Karma...');
return new Promise(resolve => { return new Promise(resolve => {
const karma = require('karma'); const karma = require('karma');
new karma.Server( new karma.Server(
...@@ -322,5 +326,5 @@ async function buildAndRunTests() { ...@@ -322,5 +326,5 @@ async function buildAndRunTests() {
// Unit and integration testing tasks. // Unit and integration testing tasks.
// //
// Some (eg. a11y) tests rely on CSS bundles. We assume that JS will always take // Some (eg. a11y) tests rely on CSS bundles. We assume that JS will always take
// londer to build than CSS, so build in parallel. // longer to build than CSS, so build in parallel.
gulp.task('test', gulp.parallel('build-css', buildAndRunTests)); gulp.task('test', gulp.parallel('build-css', buildAndRunTests));
...@@ -18,7 +18,8 @@ export default { ...@@ -18,7 +18,8 @@ export default {
treeshake: false, treeshake: false,
plugins: [ plugins: [
// Replace some problematic dependencies which are imported but not actually // Replace some problematic dependencies which are imported but not actually
// used with stubs. // used with stubs. Per @rollup/plugin-virtual's docs, this must be listed
// first.
virtual({ virtual({
// Enzyme dependency used in its "Static Rendering" mode, which we don't use. // Enzyme dependency used in its "Static Rendering" mode, which we don't use.
'cheerio/lib/utils': '', 'cheerio/lib/utils': '',
...@@ -70,7 +71,16 @@ export default { ...@@ -70,7 +71,16 @@ export default {
], ],
], ],
}), }),
nodeResolve({ browser: true, preferBuiltins: false }), nodeResolve({
browser: true,
// Disallow use of browser polyfills for Node builtin modules. We're
// trying to avoid dependencies which rely on these.
//
// There are a couple of references to Node builtins that are stubbed by
// configuration for the `virtual` plugin above.
preferBuiltins: false,
}),
commonjs(), commonjs(),
string({ string({
include: '**/*.{html,svg}', include: '**/*.{html,svg}',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment