Skip to content
This repository has been archived by the owner on Aug 5, 2020. It is now read-only.

SELA-301 Support Mocha without Karma as a test runner. #131

Merged
merged 2 commits into from
May 3, 2016

Conversation

threehams
Copy link
Collaborator

@threehams threehams commented May 3, 2016

Set up Mocha to run tests without needing to spin up a browser or bundle. This is very close to a drop-in replacement right now.

Changes

  • Assets (scss, svg, png) need to change to use relative paths. require.extensions only works for file imports, not for modules, and anything without a relative path is assumed to be a module. This means that anything using a path such as import ribbonUrl from "assets/img/icons/ribbon.svg" will pass in the Karma tests, and work in the app, but fail tests using Mocha.

I'm trying to find a way to get this working, but the directory aliasing is done through Webpack, and is not based on any standard.

Benchmarks

Mocha + Karma + Webpack

Startup time: 43 seconds
Time from file save to results: 10-11 seconds

Mocha + Node

Startup time: 4 seconds
Time from file save to results: 400-800 ms

// override to run tests in Node without Karma/Webpack
if (options.mochaOnly) {
const helperPath = path.join(__dirname, "..", "lib", "testHelperMocha.js");
const testPath = `${CWD}/test/**/*.js`;
Copy link
Contributor

Choose a reason for hiding this comment

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

If we want to be consistent with our karma test helper, we'd use *.test.js as opposed to *.js at the end here: https://github.com/TrueCar/gluestick/blob/develop/src/lib/testHelper.js#L11

@threehams threehams changed the title [WIP] SELA-301 Support Mocha without Karma as a test runner. SELA-301 Support Mocha without Karma as a test runner. May 3, 2016
Filter to only run .test.js files.
Add lots of comments around the wackier bits.
@christinebrass
Copy link
Contributor

👍

@christinebrass christinebrass merged commit 9a23602 into develop May 3, 2016
@christinebrass christinebrass deleted the feature/SELA-301 branch May 3, 2016 19:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants