Skip to content

Commit

Permalink
Revert "chore: replace karma with intern"
Browse files Browse the repository at this point in the history
This reverts commit b664b4a.
  • Loading branch information
Nick Woodward committed Apr 4, 2019
1 parent 176e9d7 commit 6f70ffb
Show file tree
Hide file tree
Showing 27 changed files with 188 additions and 118 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ branches:
script:
- npm start lint
- npm start check-types
- if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then npm start test.ci; fi
- if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then npm start test.sauce; fi
- npm start test
after_success:
- npm start report-coverage
# - npm start semantic-release
addons:
chrome: stable # have Travis install Chrome stable.
sauce_connect: true
notifications:
email: change
40 changes: 0 additions & 40 deletions intern.json

This file was deleted.

82 changes: 82 additions & 0 deletions karma.ci.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
const common = require('./rollup.common.config.js');

module.exports = (config) => {
const lastTwoVersions = ['Chrome', 'Firefox', 'MicrosoftEdge', 'Safari'].reduce((output, browser) => {
// TODO: For some reason Safari 12 throws a 500 error...
output[`${browser}Latest`] = {
base: 'SauceLabs',
browserName: browser.toLowerCase(),
version: browser === 'Safari' ? 'latest-1' : 'latest'
};

output[`${browser}Prior`] = {
base: 'SauceLabs',
browserName: browser.toLowerCase(),
version: browser === 'Safari' ? 'latest-2' : 'latest-1'
};
return output;
}, {});

const customLaunchers = Object.assign(lastTwoVersions, {
InternetExplorer11: {
base: 'SauceLabs',
browserName: 'internet explorer',
version: '11'
}
});

config.set({
basePath: '',

frameworks: [
'mocha'
],

files: [
'test/index.js'
],

client: {
mocha: {
timeout: 10000
}
},

preprocessors: {
'test/index.js': ['rollup', 'sourcemap']
},

rollupPreprocessor: common({
minified: false,
es6: false,
tests: true,
coverage: false
}),

reporters: ['mocha', 'coverage'],

mochaReporter: {
output: 'minimal',
showDiff: true
},

port: 9876,

colors: true,

logLevel: config.LOG_INFO,

sauceLabs: {
testName: 'salte-auth/salte-auth',
tunnelIdentifier: process.env.TRAVIS_JOB_NUMBER,
startConnect: false
},

customLaunchers: customLaunchers,
browsers: Object.keys(customLaunchers),
captureTimeout: 120000,
browserNoActivityTimeout: 120000,

singleRun: true
});
}
54 changes: 54 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
const common = require('./rollup.common.config.js');

module.exports = (config) => {
config.set({
basePath: '',

frameworks: [
'mocha'
],

files: [
'test/index.js'
],

preprocessors: {
'test/index.js': ['rollup', 'sourcemap'],
},

rollupPreprocessor: common({
minified: false,
es6: false,
tests: true,
coverage: true
}),

reporters: ['mocha', 'coverage'],

coverageReporter: {
dir: 'coverage',
reporters: [
{ type: 'text' },
{ type: 'lcovonly', subdir: '.', file: 'lcov.info' }
]
},

mochaReporter: {
showDiff: true
},

port: 9876,

colors: true,

logLevel: config.LOG_INFO,

autoWatch: true,

browsers: ['ChromeHeadless'],

browserNoActivityTimeout: 120000,

singleRun: false
});
}
10 changes: 5 additions & 5 deletions package-scripts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ scripts:
description: Validates that types are being used properly.
test:
default:
script: rollup -c rollup.test.config.js && intern config=@coverage
script: karma start karma.conf.js --single-run
description: Executes the Test Suite
tdd:
script: watch "rollup -c rollup.test.config.js && intern config=@coverage" src/ test/
script: karma start karma.conf.js
description: Watches for changes and executes the Test Suite accordingly
ci:
script: rollup -c rollup.test.config.js && intern config=@ci
description: Executes the Test Suite on BrowserStack
sauce:
script: karma start karma.ci.conf.js
description: Executes the Test Suite on Sauce Labs
serve:
script: rollup -c rollup.serve.config.js --watch
description: Starts a server at http://localhost:8080
Expand Down
12 changes: 10 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,17 @@
"diff": "^4.0.1",
"eslint": "^5.15.3",
"eslint-plugin-compat": "^3.1.0",
"eslint-plugin-mocha": "^5.3.0",
"husky": "^1.3.1",
"intern": "^4.4.2",
"karma": "^4.0.1",
"karma-chrome-launcher": "^2.2.0",
"karma-coverage": "^1.1.2",
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.5",
"karma-rollup-preprocessor": "^7.0.0",
"karma-sauce-launcher": "^2.0.2",
"karma-sourcemap-loader": "^0.3.7",
"mocha": "^6.0.2",
"nanoid": "^2.0.1",
"nps": "^5.9.4",
"remove-lockfiles": "^2.1.3",
Expand All @@ -63,7 +72,6 @@
"typescript": "^3.0.0",
"universal-base64url": "^1.0.0",
"url-polyfill": "^1.1.5",
"watch": "^1.0.2",
"whatwg-fetch": "^3.0.0"
},
"publishConfig": {
Expand Down
10 changes: 1 addition & 9 deletions rollup.common.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,8 @@ const copy = require('rollup-plugin-copy-assets-to');
const { name, contributors, version, browserslist } = require('./package.json');

module.exports = function({ minified, es6, coverage, tests, server }) {
let input = 'src/salte-auth.ts';

if (server) {
input = 'demo/index.ts';
} else if (tests) {
input = 'test/index.js';
}

return {
input,
input: server ? 'demo/index.ts' : 'src/salte-auth.ts',
external: ['regenerator-runtime/runtime'],
output: {
file: `dist/salte-auth${minified ? '.min' : ''}.${es6 ? 'mjs' : 'js'}`,
Expand Down
8 changes: 0 additions & 8 deletions rollup.test.config.js

This file was deleted.

5 changes: 5 additions & 0 deletions test/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
extends: ../.eslintrc.yml
plugins:
- mocha
env:
mocha: true
3 changes: 1 addition & 2 deletions test/salte-auth/base/core/events.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const { describe, it } = intern.getPlugin('interface.bdd');
const { expect } = intern.getPlugin('chai');
import { expect } from 'chai';

import { Events } from '../../../../src/base/core/events';

Expand Down
3 changes: 1 addition & 2 deletions test/salte-auth/base/core/provider.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const { describe, it } = intern.getPlugin('interface.bdd');
const { expect } = intern.getPlugin('chai');
import { expect } from 'chai';

import { Provider } from '../../../../src/base/core/provider';

Expand Down
3 changes: 1 addition & 2 deletions test/salte-auth/base/core/required.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const { describe, it } = intern.getPlugin('interface.bdd');
const { expect } = intern.getPlugin('chai');
import { expect } from 'chai';

import { SalteAuthError } from '../../../../src/base/core/salte-auth-error';
import { Required } from '../../../../src/base/core/required';
Expand Down
3 changes: 1 addition & 2 deletions test/salte-auth/base/core/salte-auth-error.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const { describe, it } = intern.getPlugin('interface.bdd');
const { expect } = intern.getPlugin('chai');
import { expect } from 'chai';

import { SalteAuthError } from '../../../../src/base/core/salte-auth-error';

Expand Down
3 changes: 1 addition & 2 deletions test/salte-auth/base/core/shared.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const { describe, it } = intern.getPlugin('interface.bdd');
const { expect } = intern.getPlugin('chai');
import { expect } from 'chai';

import { Shared } from '../../../../src/base/core/shared';

Expand Down
3 changes: 1 addition & 2 deletions test/salte-auth/base/core/storage.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const { describe, it, beforeEach } = intern.getPlugin('interface.bdd');
const { expect } = intern.getPlugin('chai');
import { expect } from 'chai';

import { SalteAuthError } from '../../../../src/base/core/salte-auth-error';
import { Storage } from '../../../../src/base/core/storage';
Expand Down
3 changes: 1 addition & 2 deletions test/salte-auth/base/handler.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const { describe, it } = intern.getPlugin('interface.bdd');
const { expect } = intern.getPlugin('chai');
import { expect } from 'chai';

import { Handler } from '../../../src/base/handler';

Expand Down
4 changes: 1 addition & 3 deletions test/salte-auth/base/provider-oauth2.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
const { describe, it, beforeEach, afterEach } = intern.getPlugin('interface.bdd');
const chai = intern.getPlugin('chai');

import chai from 'chai';
import chaiString from 'chai-string';
import sinon from 'sinon';

Expand Down
4 changes: 1 addition & 3 deletions test/salte-auth/base/provider-openid.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
const { describe, it, beforeEach, afterEach } = intern.getPlugin('interface.bdd');
const chai = intern.getPlugin('chai');

import chai from 'chai';
import chaiString from 'chai-string';
import sinon from 'sinon';

Expand Down
3 changes: 1 addition & 2 deletions test/salte-auth/generic.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const { describe, it, beforeEach } = intern.getPlugin('interface.bdd');
const { expect } = intern.getPlugin('chai');
import { expect } from 'chai';

import { OAuth2, OpenID } from '../../src/generic';

Expand Down
4 changes: 1 addition & 3 deletions test/salte-auth/salte-auth.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
const { describe, it, beforeEach, afterEach } = intern.getPlugin('interface.bdd');
const chai = intern.getPlugin('chai');

import chai from 'chai';
import chaiSinon from 'chai-sinon';
import sinon from 'sinon';

Expand Down
10 changes: 6 additions & 4 deletions test/salte-auth/utils/common.spec.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const { describe, it, beforeEach, afterEach } = intern.getPlugin('interface.bdd');
const { expect } = intern.getPlugin('chai');

import chai from 'chai';
import sinon from 'sinon';

import { Common } from '../../../src/utils/common';
import { getError } from '../../utils/get-error';

describe('Utils.Common', () => {
const { expect } = chai;

describe('Common', () => {
afterEach(() => {
sinon.restore();
});
Expand Down Expand Up @@ -83,7 +83,9 @@ describe('Utils.Common', () => {
hallo: 'welt'
});
});
});

describe('function(defaults)', () => {
it('should support merging defaults into an existing object', () => {
const output = Common.defaults({
hallo: 'welt'
Expand Down
4 changes: 1 addition & 3 deletions test/salte-auth/utils/events.spec.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
const { describe, it, before, after } = intern.getPlugin('interface.bdd');

import sinon from 'sinon';

import { Events } from '../../../src/utils/events';

describe('Utils.Events', () => {
describe('Events', () => {
let events = {};
before(() => {
sinon.stub(window, 'addEventListener').callsFake((name, listener) => {
Expand Down

0 comments on commit 6f70ffb

Please sign in to comment.