Skip to content

Commit

Permalink
Add IE11 testing via BrowserStack to the test matrix.
Browse files Browse the repository at this point in the history
This aligns the plugin with the support level in core. Note that this
commit also ensures the Chrome headless tests run on CI.
  • Loading branch information
alexjeffburke committed Dec 6, 2020
1 parent fc0a113 commit 560b431
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 7 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Expand Up @@ -3,6 +3,10 @@ name: Tests
push:
pull_request:

env:
BROWSER_STACK_ACCESS_KEY: '${{ secrets.BROWSER_STACK_ACCESS_KEY }}'
BROWSER_STACK_USERNAME: '${{ secrets.BROWSER_STACK_USERNAME }}'

jobs:
test:
runs-on: ubuntu-18.04
Expand Down Expand Up @@ -32,6 +36,10 @@ jobs:
target: 'lint'
- name: 'Coverage'
target: 'coverage'
- name: 'Browser - IE11'
target: 'test-browser-ie11'
- name: 'Chrome Headless'
target: 'test-headless'

steps:
- uses: actions/checkout@v2
Expand Down
14 changes: 13 additions & 1 deletion karma.conf.js
Expand Up @@ -15,6 +15,18 @@ module.exports = function (config) {
},
},

browsers: ['ChromeHeadless'],
browsers: ['ChromeHeadless', 'ie11'],

customLaunchers: {
ie11: {
base: 'BrowserStack',
browser: 'IE',
browser_version: '11',
os: 'Windows',
os_version: '7',
},
},

reporters: ['dots', 'BrowserStack'],
});
};
7 changes: 5 additions & 2 deletions package.json
Expand Up @@ -10,10 +10,12 @@
"unexpected-snapshot-browser.js.map"
],
"scripts": {
"build": "./build.sh",
"lint": "eslint . && prettier --check '**/*.{js,md}'",
"test": "mocha",
"build": "./build.sh",
"test-headless": "npm run build && karma start --single-run",
"test-browser": "npm run build && karma start --single-run --browsers ${BROWSER:-ChromeHeadless}",
"test-browser-ie11": "BROWSER=ie11 npm run test-browser",
"test-headless": "npm run test-browser",
"coverage": "nyc --reporter=lcov --reporter=text --all -- mocha && echo google-chrome coverage/lcov-report/index.html",
"prepublishOnly": "npm run build",
"preversion": "offline-github-changelog --next=${npm_package_version} > CHANGELOG.md && git add CHANGELOG.md"
Expand Down Expand Up @@ -43,6 +45,7 @@
"eslint-plugin-standard": "^5.0.0",
"espree": "^7.0.0",
"karma": "^5.0.1",
"karma-browserstack-launcher": "^1.6.0",
"karma-chrome-launcher": "^3.0.0",
"karma-mocha": "^2.0.0",
"mocha": "^8.0.1",
Expand Down
12 changes: 8 additions & 4 deletions test/browser/index.js
@@ -1,6 +1,7 @@
/* global weknowhow, unexpectedSnapshot */

const expect = weknowhow.expect.clone().use(unexpectedSnapshot);
// eslint-disable-next-line no-var
var expect = weknowhow.expect.clone().use(unexpectedSnapshot);

describe('unexpected-snapshot', function () {
describe('to equal snapshot', function () {
Expand All @@ -10,7 +11,9 @@ describe('unexpected-snapshot', function () {

it('should fail with a diff', function () {
expect(
() => expect('abc', 'to equal snapshot', 'def'),
function () {
expect('abc', 'to equal snapshot', 'def');
},
'to throw',
"expected 'abc' to equal snapshot 'def'\n" +
'\n' +
Expand All @@ -37,12 +40,13 @@ describe('unexpected-snapshot', function () {

it('should fail with a diff', function () {
expect(
() =>
function () {
expect(
new Person('Eigil'),
'to equal snapshot',
"Person({ name: 'Preben' })"
),
);
},
'to throw',
"expected Person({ name: 'Eigil' }) to equal snapshot 'Person({ name: \\'Preben\\' })'\n" +
'\n' +
Expand Down

0 comments on commit 560b431

Please sign in to comment.