Skip to content

Commit

Permalink
Merge pull request #705 from recurly/unit-split-ie
Browse files Browse the repository at this point in the history
Adds unit test suite partitioning for IE 11
  • Loading branch information
douglasmiller authored Jan 31, 2022
2 parents 75b8849 + 9c74867 commit 87dbe6c
Show file tree
Hide file tree
Showing 12 changed files with 19,765 additions and 21,201 deletions.
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ jobs:
env: BROWSER=BrowserStackSafari
- name: Edge
env: BROWSER=BrowserStackEdge
- name: Internet Explorer 11
env: BROWSER=BrowserStackIe11
- name: Internet Explorer 11 A
env: BROWSER=BrowserStackIe11 SUITE_PARTITION=A
- name: Internet Explorer 11 B
env: BROWSER=BrowserStackIe11 SUITE_PARTITION=B
- name: iOS 14
env: BROWSER=BrowserStackIos14
- name: iOS 13
Expand Down
4 changes: 4 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ const staticConfig = {
proxies: {
'/api': 'http://localhost:9877'
},
preprocessors: {
'**/*.js': ['env']
},
envPreprocessor: ['SUITE_PARTITION'],
hostname: (BROWSER.includes('Android') ? '10.0.2.2' : 'localhost'),
reporters: ['mocha', 'coverage'],
port: 9876,
Expand Down
40,888 changes: 19,700 additions & 21,188 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@
"babel-eslint": "^10.0.3",
"babel-loader": "^8.2.1",
"babel-plugin-istanbul": "^6.0.0",
"chromedriver": "^85.0.1",
"chromedriver": "^89.0.0",
"combinations": "^1.0.0",
"coveralls": "^3.1.0",
"css-loader": "^3.6.0",
"current-git-branch": "^1.1.0",
"dtslint": "^3.7.0",
"electron": "^10.1.5",
"electron": "^12.2.3",
"eslint": "^6.8.0",
"geckodriver": "^1.20.0",
"glob": "^7.1.6",
Expand All @@ -76,7 +76,8 @@
"karma-browserstack-launcher": "^1.6.0",
"karma-chrome-launcher": "^3.1.0",
"karma-coverage": "^2.0.3",
"karma-electron": "^6.3.1",
"karma-electron": "^7.1.0",
"karma-env-preprocessor": "^0.1.1",
"karma-firefox-launcher": "^1.3.0",
"karma-ios-simulator-launcher": "git+https://[email protected]/chrissrogers/karma-ios-simulator-launcher.git",
"karma-mocha": "^2.0.1",
Expand Down
7 changes: 6 additions & 1 deletion test/unit/paypal/paypal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ import after from 'lodash.after';
import { PayPal } from '../../../lib/recurly/paypal';
import { DirectStrategy } from '../../../lib/recurly/paypal/strategy/direct';
import { BraintreeStrategy } from '../../../lib/recurly/paypal/strategy/braintree';
import { initRecurly, apiTest, stubBraintree, stubWindowOpen } from '../support/helpers';
import {
initRecurly,
apiTest,
stubBraintree,
stubWindowOpen
} from '../support/helpers';

apiTest(function (requestMethod) {
describe(`Recurly.PayPal (${requestMethod})`, function () {
Expand Down
7 changes: 6 additions & 1 deletion test/unit/paypal/strategy/braintree.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import assert from 'assert';
import each from 'component-each';
import merge from 'lodash.merge';
import { Recurly } from '../../../../lib/recurly';
import { initRecurly, apiTest, stubBraintree, stubWindowOpen } from '../../support/helpers';
import {
initRecurly,
apiTest,
stubBraintree,
stubWindowOpen
} from '../../support/helpers';

apiTest(function (requestMethod) {
describe(`BraintreeStrategy (${requestMethod})`, function () {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/pricing/checkout/checkout.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import assert from 'assert';
import after from 'lodash.after';
import isEqual from 'lodash.isequal';
import {initRecurly} from '../../support/helpers';
import { initRecurly } from '../../support/helpers';

describe('CheckoutPricing', function () {
beforeEach(function (done) {
Expand Down
4 changes: 2 additions & 2 deletions test/unit/pricing/subscription/attachment.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import assert from 'assert';
import {applyFixtures} from '../../support/fixtures';
import {initRecurly} from '../../support/helpers';
import { applyFixtures } from '../../support/fixtures';
import { initRecurly } from '../../support/helpers';
import PricingAttachment from '../../../../lib/recurly/pricing/subscription/attachment'

describe('Recurly.Pricing.attach', function () {
Expand Down
25 changes: 25 additions & 0 deletions test/unit/support/init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* Overrides `it` if we're partitioning the test suite
*
* to invoke, add the env variable SUITE_PARTITION. example:
*
* BROWSER=ChromeHeadless SUITE_PARTITION=A make test-unit
*/

function overrideItForPartitions () {
const origIt = it;
const partition = mod => SUITE_PARTITION === 'A' ? mod : !mod;
let count = 0;

it = function (...args) {
if (typeof args[args.length-1] === 'function' && partition(count++ % 2)) {
return origIt.skip(...args);
}
return origIt(...args);
};

it.skip = origIt.skip;
}

const { SUITE_PARTITION } = window.__env__;
if (SUITE_PARTITION) overrideItForPartitions();
7 changes: 6 additions & 1 deletion test/unit/venmo/strategy/braintree.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import assert from 'assert';
import { initRecurly, apiTest, stubBraintree, stubWindowOpen } from '../../support/helpers';
import {
initRecurly,
apiTest,
stubBraintree,
stubWindowOpen
} from '../../support/helpers';

apiTest(function (requestMethod) {
describe(`BraintreeStrategy (${requestMethod})`, function () {
Expand Down
7 changes: 6 additions & 1 deletion test/unit/venmo/venmo.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import assert from 'assert';
import after from 'lodash.after';
import { BraintreeStrategy } from '../../../lib/recurly/venmo/strategy/braintree';
import { initRecurly, apiTest, stubBraintree, stubWindowOpen } from '../support/helpers';
import {
initRecurly,
apiTest,
stubBraintree,
stubWindowOpen
} from '../support/helpers';

apiTest(function (requestMethod) {
describe(`Recurly.Venmo (${requestMethod})`, function () {
Expand Down
2 changes: 1 addition & 1 deletion webpack.test.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if (shouldInstrument()) {
}

module.exports = {
entry: glob.sync('./test/unit/**/*.test.js'),
entry: ['./test/unit/support/init.js', ...glob.sync('./test/unit/**/*.test.js')],
mode: 'development',
output: {
path: path.join(__dirname, 'build'),
Expand Down

0 comments on commit 87dbe6c

Please sign in to comment.