Skip to content

Commit

Permalink
Merge pull request #576 from fcollonval/ft/jest
Browse files Browse the repository at this point in the history
Convert test from karma to jest
  • Loading branch information
vidartf committed Apr 11, 2021
2 parents c823623 + 295e834 commit ab9f1bc
Show file tree
Hide file tree
Showing 25 changed files with 940 additions and 988 deletions.
10 changes: 3 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
language: python
python:
- 3.9-dev
- 3.9
- 3.8
- 3.7
- 3.6
sudo: false
dist: xenial
dist: bionic
services:
- xvfb
env:
Expand All @@ -24,7 +24,7 @@ cache:
before_install:
- python -c "import fcntl; fcntl.fcntl(1, fcntl.F_SETFL, 0)"
- pip install -U pip setuptools
- nvm install 8
- nvm install 14
- |
if [[ $GROUP == python ]]; then
pip install codecov
Expand All @@ -40,11 +40,7 @@ install:
pip install --upgrade --upgrade-strategy=eager -e ".[test]"
fi
before_script:
# Set up a virtual screen for Firefox browser testing:
- |
if [[ $GROUP == js ]]; then
export CHROME_BIN=chromium-browser
fi
git config --global user.email travis@fake.com
git config --global user.name "Travis CI"
script:
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ skip_branch_with_pr: true

# environment variables
environment:
nodejs_version: "8.15"
nodejs_version: "14"
matrix:
- PYTHON: "C:\\Python37-x64"
PYTHON_VERSION: "3.7.x"
Expand Down
13 changes: 13 additions & 0 deletions packages/nbdime/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
sourceMap: "inline",
presets: [
[
"@babel/preset-env",
{
targets: {
node: "current",
},
},
],
],
};
25 changes: 25 additions & 0 deletions packages/nbdime/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
var tsConfig = require ('./tsconfig.json');

var tsOptions = tsConfig["compilerOptions"];
// Need as the test folder is not visible from the src folder
tsOptions["rootDir"] = null;
tsOptions["inlineSourceMap"] = true;

module.exports = {
automock: false,
moduleNameMapper: {
'\\.(css|less|sass|scss)$': 'identity-obj-proxy',
'\\.(svg)$': '<rootDir>/test/jest-file-mock.js'
},
preset: 'ts-jest/presets/js-with-babel',
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
setupFiles: ['<rootDir>/test/jest-setup-files.js'],
testPathIgnorePatterns: ['/lib/', '/node_modules/'],
testRegex: '/test/src/.*.spec.ts$',
transformIgnorePatterns: ['/node_modules/(?!(@jupyterlab/.*)/)'],
globals: {
'ts-jest': {
tsconfig: tsOptions
}
}
};
24 changes: 9 additions & 15 deletions packages/nbdime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@
"build:dev": "tsc --project .",
"clean": "rimraf test/build && rimraf lib",
"prepublishOnly": "npm run build",
"test": "npm run test:firefox",
"test:chrome": "karma start --browsers=Chrome test/karma.conf.js",
"test:debug": "karma start --browsers=Chrome --singleRun=false --debug=true test/karma-nocov.conf.js",
"test:firefox": "karma start --browsers=Firefox test/karma.conf.js",
"test": "jest --coverage",
"watch": "tsc --build --watch"
},
"dependencies": {
Expand All @@ -37,23 +34,20 @@
"json-stable-stringify": "^1.0.1"
},
"devDependencies": {
"@babel/core": "^7.5.0",
"@babel/preset-env": "^7.5.0",
"@jupyterlab/testutils": "^2.0.0",
"@jupyterlab/apputils": "^2 || ^3",
"@lumino/messaging": "^1.2.2",
"@types/expect.js": "^0.3.29",
"@types/json-stable-stringify": "^1.0.32",
"@types/mocha": "^8.2.0",
"@types/jest": "^26.0.0",
"@types/node": "^14.14.13",
"@types/sanitizer": "^0.0.28",
"expect.js": "^0.3.1",
"fs-extra": "^8.1.0",
"karma": "^5.2.3",
"karma-chrome-launcher": "^3.1.0",
"karma-firefox-launcher": "^2.1.0",
"karma-mocha": "^2.0.1",
"karma-mocha-reporter": "^2.2.5",
"karma-typescript": "^4.0.0",
"karma-typescript-es6-transform": "^4.0.0",
"mocha": "^8.2.1",
"identity-obj-proxy": "^3.0.0",
"jest": "^26.0.0",
"jest-fetch-mock": "^1.6.6",
"ts-jest": "^26.0.0",
"rimraf": "^2.6.3",
"typescript": "^3.7.2"
},
Expand Down
1 change: 1 addition & 0 deletions packages/nbdime/test/jest-file-mock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = 'test-file-stub';
1 change: 1 addition & 0 deletions packages/nbdime/test/jest-setup-files.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
global.fetch = require('jest-fetch-mock');
46 changes: 0 additions & 46 deletions packages/nbdime/test/karma-nocov.conf.js

This file was deleted.

20 changes: 0 additions & 20 deletions packages/nbdime/test/karma.conf.js

This file was deleted.

4 changes: 1 addition & 3 deletions packages/nbdime/test/src/common/collapsiblepanel.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.

import expect = require('expect.js');

import {
Widget
} from '@lumino/widgets';
Expand All @@ -18,7 +16,7 @@ describe('common', () => {
it('should be initialized with an inner widget', () => {
let inner = new Widget();
let p = new CollapsiblePanel(inner);
expect(p).to.not.be(null);
expect(p).not.toBe(null);
});

});
Expand Down
6 changes: 1 addition & 5 deletions packages/nbdime/test/src/common/dragpanel.spec.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.

import expect = require('expect.js');

import {
DragDropPanel
} from '../../../src/common/dragpanel';



describe('common', () => {

describe('DragPanel', () => {

it('should be initialized with no options', () => {
let p = new DragDropPanel();
expect(p).to.not.be(null);
expect(p).not.toBe(null);
});

});
Expand Down

0 comments on commit ab9f1bc

Please sign in to comment.