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

Skip to content

Better test-jasmine karma.conf.js with minimist #1524

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

Merged
merged 6 commits into from
Mar 29, 2017

Conversation

etpinard
Copy link
Contributor

@etpinard etpinard commented Mar 29, 2017

This PR 🔪 citest-jasmine test script and allows easier and better configuration of our jasmine test runner using the minimist argument parser.

From the new npm run test-jasmine -- --info output:

plotly.js karma runner for jasmine tests CLI info

Examples:

Run `axes_test.js`, `bar_test.js` and `scatter_test.js` suites w/o the `autoWatch` mode:
  $ npm run test-jasmine -- axes bar_test.js scatter --nowatch

Run all tests with the `noCI` tag on Firefox in a 1500px wide window:
  $ npm run test-jasmine -- --tags=noCI --FF --width=1500

Run the `ie9_test.js` bundle test with the verbose reporter:
  $ npm run test-jasmine -- --bundleTest=ie9 --verbose

Arguments:
  - All non-flagged arguments corresponds to the test suites in `test/jasmine/tests/` to be run.
    No need to add the `_test.js` suffix, we expand them correctly here.
  - `--bundleTest` set the bundle test suite `test/jasmine/bundle_tests/ to be run.
    Note that only one bundle test can be run at a time.

Other options:
  - `--info`: show this info message
  - `--Chrome` (alias `--chrome`): run test in (our custom) Chrome browser
  - `--Firefox` (alias `--FF`, `--firefox`): run test in (our custom) Firefox browser
  - `--watch (dflt: `false`)`: run karma in `autoWatch` / multiple run mode
  - `--verbose` (dflt: `false`): show test result using verbose reporter
  - `--tags`: run only test with given tags (using the `jasmine-spec-tags` framework)
  - `--width`(dflt: 1035): set width of the browser window
  - `--height` (dflt: 617): set height of the browser window

For info on the karma CLI options run `npm run test-jasmine -- --help`

@alexcjohnson @rreusser @monfera @n-riesco I hope you like the improvements.

- better handle test suite arguments (normalize file name)
- add --bundleTest=<> argument to make testing bundle test
  easier to run
- add --watch, --verbose, --width, --height and --info flags
- use npm run test-jasmine arguments instead!
},
'default': {
info: false,
watch: false,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

watch is set to false by default so that npm run test-jasmine exits on complete by default.

We could alternatively make npm run test-jasmine auto-watch and auto-rerun like previously and a --no-watch flag instead. I'm open to suggestions

Copy link
Collaborator

Choose a reason for hiding this comment

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

I like having watch on 99% of the time. And even when I don't want to run multiple times (ie when I'm running the full suite) it's easy enough to just ctrl-c at the end. So I'd definitely vote to flip the default.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done in 7cf9943

return _.length === 1 ?
_[0] + SUFFIX :
'{' + _.join(',') + '}' + SUFFIX;
};
Copy link
Contributor Author

@etpinard etpinard Mar 29, 2017

Choose a reason for hiding this comment

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

This logic ⤴️ is to normalize the test file name inputs, so that:

npm run test-jasmine -- axes bar scatter

does the same as

npm run test-jasmine -- axes_test.js tests/scatter_test.js bar

I hope you enjoy not having to type those tests/ and _test.js to run individual test suites.

Copy link
Contributor

@rreusser rreusser Mar 29, 2017

Choose a reason for hiding this comment

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

THIS IS GREAT. Though I'd mostly internalized tests/*.js, it's a real nice feature, especially for newcomers!

- `nowatch` is false by default locally and true by default on CI
@alexcjohnson
Copy link
Collaborator

Love it! 💃

@etpinard etpinard merged commit 7f07d51 into plotly:master Mar 29, 2017
@etpinard etpinard deleted the karma-conf-minimist branch March 29, 2017 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants