Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task/jenkins 43083 testing improvements #1002

Merged
merged 40 commits into from Jun 13, 2017
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
9648f5e
[JENKINS-43083] add support for testing via jest with "npm run test"
Apr 20, 2017
da7978d
[JENKINS-43083] run jest via gulp instead
Apr 20, 2017
9925505
[JENKINS-43083] add junit reporting; provide two different tasks for …
Apr 20, 2017
9d665ba
[JENKINS-43083] ensure failed test breaks build
Apr 20, 2017
54647f5
[JENKINS-43083] ensure unhandled error breaks build
Apr 20, 2017
74216a4
[JENKINS-43083] remove failure
Apr 20, 2017
7050859
[JENKINS-43083] support "test" "test-fast" and "test-debug" npm scrip…
Apr 24, 2017
8c5c997
[JENKINS-43083] refactor code to use "runJest" function which adds pr…
Apr 24, 2017
c72fd08
[JENKINS-43083] docs about tests
Apr 24, 2017
cb1399c
[JENKINS-43083] use Jest mocking to provide a "no-op" implementation …
Apr 25, 2017
ca6c391
[JENKINS-43083] switch from "before" to "beforeAll"
Apr 28, 2017
6839281
[JENKINS-43083] WIP for running jjsbuilder tests with Jest; still nee…
May 8, 2017
a4cf207
[JENKINS-43083] ignore jest reports
May 10, 2017
0dce085
[JENKINS-43083] dashboard uses Jest and minor tweaks to use "beforeAll"
May 10, 2017
a5ff04b
[JENKINS-43083] export a named function to avoid test breakage when u…
May 10, 2017
a33c509
[JENKINS-43083] personalization uses Jest; use different approach to …
May 10, 2017
b096a46
[JENKINS-43083] eliminate obsolete mocking code that is no longer needed
May 10, 2017
a98de77
[JENKINS-43083] typo in coverage dir name
Apr 25, 2017
c3cea0d
Merge branch 'master' into task/JENKINS-43083-testing-improvements
May 11, 2017
b0f5227
Merge branch 'master' into task/JENKINS-43083-testing-improvements
May 18, 2017
fce4528
[JENKINS-43083] use i18n mock in TimeHarmonizer
May 18, 2017
78e55e9
[JENKINS-43083] fix weird package.json / shrink entry for js-builder-…
May 18, 2017
b6b75af
Merge branch 'master' into task/JENKINS-43083-testing-improvements
May 25, 2017
fb21ec4
fix test that was intentionally failing
May 25, 2017
3da6886
Merge branch 'master' into task/JENKINS-43083-testing-improvements
May 25, 2017
6f7dbfe
invoke gulp natively (bypassing jjsb command line) to facilitate debu…
May 25, 2017
8f64714
update shrinkwrap to include jest and related libs
May 26, 2017
6d41d8f
Merge branch 'master' into task/JENKINS-43083-testing-improvements
May 26, 2017
b903dba
experiment with adding jest junit reports
May 26, 2017
9bd0816
align run script naming w/ dashboard and personalization
May 26, 2017
aa3146f
verify that core-js tests are being picked up
May 26, 2017
7de78da
re-enable test
May 26, 2017
e804953
updating to master
michaelneale May 30, 2017
8abc740
Merge branch 'master' into task/JENKINS-43083-testing-improvements
May 30, 2017
53c6af6
Merge branch 'master' into task/JENKINS-43083-testing-improvements
michaelneale May 31, 2017
682bcb5
Merge branch 'master' into task/JENKINS-43083-testing-improvements
Jun 1, 2017
11412ba
Merge branch 'master' into task/JENKINS-43083-testing-improvements
imeredith Jun 6, 2017
5fa3b66
Merge branch 'master' into task/JENKINS-43083-testing-improvements
Jun 6, 2017
ab66686
Merge branch 'master' into task/JENKINS-43083-testing-improvements
Jun 7, 2017
f623b37
Merge branch 'master' into task/JENKINS-43083-testing-improvements
Jun 13, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions blueocean-core-js/.gitignore
Expand Up @@ -5,4 +5,5 @@ dist
*.iml
.idea/
/.project
coverage
reports
26 changes: 26 additions & 0 deletions blueocean-core-js/README.md
@@ -1,3 +1,29 @@
# Blue Ocean Core JS

This is an npm module that contains common javascript libraries/utilities that are used across modules and plugins and blue oceans.

# Running Tests

Tests are run via jest using the gulp-jest plugin. Three modes of execution are supported:

## `npm run test`

Runs jest and outputs JUnit test reports and code coverage metrics, in the 'reports' and 'coverage' dirs.
This is the "full" execution that is run in CI.

## `npm run test-fast`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe this should be default? vs the one above? how much overhead does it really ad?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hrm no - I now disagree with myself. Carry on.


Runs jest without test reports or coverage. Fastest run, useful for local development.

## `npm run test-debug`

Runs jest in debug mode listening on localhost:5858. You must attach a debugger for execution to proceed.
Test reports and coverage are skipped.

## Running select test(s)

All of the above profiles support executing one or more tests via jest's `testPathPattern` parameter:

`npm run test-fast -- --test test/js/UrlUtils-spec.js` // one test
`npm run test-fast -- --test /capability/` // any tests in a 'capability' dir
`npm run test-fast -- --test Url` // any test with 'Url' in the name
65 changes: 59 additions & 6 deletions blueocean-core-js/gulpfile.js
Expand Up @@ -14,12 +14,14 @@ const del = require('del');
const runSequence = require('run-sequence');
const lint = require('gulp-eslint');
const Karma = require('karma').Server;
const jest = require('gulp-jest').default;
const fs = require('fs');
const minimist = require('minimist');

// Options, src/dest folders, etc

const config = {
clean: ["dist", "licenses", "reports"],
clean: ["covarage", "dist", "licenses", "reports"],
react: {
sources: "src/**/*.{js,jsx}",
dest: "dist"
Expand All @@ -33,13 +35,16 @@ const config = {
less_assets: {
sources: "src/less/**/*.svg",
dest: "dist/assets/css"
}
},
},
test: {
sources: "test/**/*-spec.{js,jsx}"
}
sources: '.',
match: ['**/?(*-)(spec|test).js?(x)'],
output: 'reports/junit.xml',
},
};


// Watch all

gulp.task("watch", ["clean-build"], () => {
Expand Down Expand Up @@ -71,9 +76,11 @@ gulp.task("lint", () => (
.pipe(lint.failAfterError())
));

gulp.task("test", ['test-karma']);
gulp.task("test", ['test-jest']);

gulp.task("test-debug", ['test-karma-debug']);
gulp.task("test-debug", ['test-jest-debug']);

gulp.task("test-fast", ['test-jest-fast']);

gulp.task("test-karma", (done) => {
new Karma({
Expand All @@ -91,6 +98,52 @@ gulp.task("test-karma-debug", (done) => {
}, done).start();
});

function runJest(options) {
const argv = minimist(process.argv.slice(2));
options.testPathPattern = argv.test || null;

return gulp.src(config.test.sources)
.pipe(jest(options))
.on('error', () => {
process.exit(1);
});
}

gulp.task('test-jest', () => {
if (!process.env.JEST_JUNIT_OUTPUT) {
process.env.JEST_JUNIT_OUTPUT = config.test.output;
}

runJest({
config: {
collectCoverage: true,
testMatch: config.test.match,
testResultsProcessor: 'jest-junit',
},
});
});

gulp.task('test-jest-fast', () =>
runJest({
notify: true,
forceExit: true,
config: {
testMatch: config.test.match,
},
})
);

gulp.task('test-jest-debug', () =>
runJest({
runInBand: true,
forceExit: true,
config: {
testMatch: config.test.match,
},
})
);


// Build all

gulp.task("build", ["compile-react", "less", "copy"]);
Expand Down