Skip to content

Commit

Permalink
Merge pull request #6219 from blink1073/upgrade-ts-jest
Browse files Browse the repository at this point in the history
Switch to esnext imports
  • Loading branch information
blink1073 committed Apr 25, 2019
2 parents 13a8543 + 4c8c7f1 commit 7844502
Show file tree
Hide file tree
Showing 31 changed files with 679 additions and 45 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Adding `--user` after `pip install` will install the files to a local user insta

#### pipenv

`Pipenv` provides users and developers of applications with an easy method to setup a working environment, however Python must be installed first. See the [pipenv installation documentation](https://docs.pipenv.org/install) to use Pipenv if it is not installed.
`Pipenv` provides users and developers of applications with an easy method to setup a working environment, however Python must be installed first. See the [pipenv installation documentation](https://docs.pipenv.org/en/latest/install/) to use Pipenv if it is not installed.

`pipenv` can be installed as:

Expand Down
3 changes: 2 additions & 1 deletion buildutils/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"extends": "../tsconfigbase",
"compilerOptions": {
"outDir": "lib",
"rootDir": "src"
"rootDir": "src",
"module": "commonjs"
},
"include": ["src/*"]
}
3 changes: 2 additions & 1 deletion packages/coreutils/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"extends": "../../tsconfigbase",
"compilerOptions": {
"outDir": "lib",
"rootDir": "src"
"rootDir": "src",
"module": "commonjs"
},
"files": ["src/plugin-schema.json"],
"include": ["src/*"]
Expand Down
2 changes: 1 addition & 1 deletion packages/rendermime/src/renderers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { IRenderMime } from '@jupyterlab/rendermime-interfaces';

import { toArray } from '@phosphor/algorithm';

import escape = require('lodash.escape');
import escape from 'lodash.escape';

import { removeMath, replaceMath } from './latex';

Expand Down
1 change: 1 addition & 0 deletions packages/services/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"compilerOptions": {
"outDir": "lib",
"rootDir": "src",
"module": "commonjs",
"types": ["node"]
},
"include": ["src/**/*"],
Expand Down
14 changes: 1 addition & 13 deletions packages/terminal-extension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,19 +403,7 @@ namespace Private {
return widgetReady;
}

widgetReady = new Promise((resolve, reject) => {
require.ensure(
['@jupyterlab/terminal/lib/widget'],
// see https://webpack.js.org/api/module-methods/#require-ensure
// this argument MUST be named `require` for the WebPack parser
require => resolve(require('@jupyterlab/terminal/lib/widget')),
(error: any) => {
showErrorMessage(error);
reject();
},
'terminal'
);
});
widgetReady = import('@jupyterlab/terminal/lib/widget');

return widgetReady;
}
Expand Down
17 changes: 1 addition & 16 deletions packages/vega5-extension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,22 +188,7 @@ namespace Private {
return vegaReady;
}

vegaReady = new Promise((resolve, reject) => {
require.ensure(
['vega-embed'],
// see https://webpack.js.org/api/module-methods/#require-ensure
// this argument MUST be named `require` for the WebPack parser
require => {
vega = require('vega-embed') as typeof VegaModuleType;
resolve(vega);
},
(error: any) => {
console.error(error);
reject();
},
'vega'
);
});
vegaReady = import('vega-embed');

return vegaReady;
}
Expand Down
6 changes: 4 additions & 2 deletions tests/convert-to-jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ utils.writeJSONFile(path.join(testSrc, 'tsconfig.json'), tsData);
utils.run(`git rm -f ./test-${name}/${fname}`);
});

// Copy run.py from coreutils
fs.copySync(path.join(coreUtils, 'run.py'), path.join(testSrc, 'run.py'));
// Copy common files from coreutils
['run.py', 'babel.config.js'].forEach(fname => {
fs.copySync(path.join(coreUtils, fname, path.join(testSrc, fname)));
});

// Add new files to git
utils.run(`git add ./test-${name}/run.py ./test-${name}/jest.config.js`);
Expand Down
5 changes: 4 additions & 1 deletion tests/karma-cov.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ module.exports = function(config) {
// instrument only testing sources with Istanbul
{
test: /\.js$/,
use: { loader: 'istanbul-instrumenter-loader' },
use: {
loader: 'istanbul-instrumenter-loader',
options: { esModules: true }
},
include: process.env.KARMA_COVER_FOLDER
}
);
Expand Down
2 changes: 2 additions & 0 deletions tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "1.0.0-alpha.6",
"private": true,
"dependencies": {
"@babel/preset-env": "^7.4.3",
"@jupyterlab/apputils": "^1.0.0-alpha.6",
"@jupyterlab/cells": "^1.0.0-alpha.7",
"@jupyterlab/codeeditor": "^1.0.0-alpha.6",
Expand Down Expand Up @@ -38,6 +39,7 @@
"chai": "~4.1.2",
"expect.js": "~0.3.1",
"json-to-html": "~0.1.2",
"karma-babel-preprocessor": "^8.0.0",
"react": "~16.8.4",
"simulate-event": "~1.4.0"
},
Expand Down
1 change: 1 addition & 0 deletions tests/test-application/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@jupyterlab/testutils/lib/babel.config');
1 change: 1 addition & 0 deletions tests/test-apputils/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@jupyterlab/testutils/lib/babel.config');
1 change: 1 addition & 0 deletions tests/test-cells/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@jupyterlab/testutils/lib/babel.config');
1 change: 1 addition & 0 deletions tests/test-codeeditor/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@jupyterlab/testutils/lib/babel.config');
1 change: 1 addition & 0 deletions tests/test-codemirror/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@jupyterlab/testutils/lib/babel.config');
1 change: 1 addition & 0 deletions tests/test-completer/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@jupyterlab/testutils/lib/babel.config');
1 change: 1 addition & 0 deletions tests/test-coreutils/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@jupyterlab/testutils/lib/babel.config');
1 change: 1 addition & 0 deletions tests/test-docregistry/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@jupyterlab/testutils/lib/babel.config');
1 change: 1 addition & 0 deletions tests/test-fileeditor/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@jupyterlab/testutils/lib/babel.config');
1 change: 1 addition & 0 deletions tests/test-imageviewer/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@jupyterlab/testutils/lib/babel.config');
1 change: 1 addition & 0 deletions tests/test-inspector/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@jupyterlab/testutils/lib/babel.config');
1 change: 1 addition & 0 deletions tests/test-mainmenu/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@jupyterlab/testutils/lib/babel.config');
1 change: 1 addition & 0 deletions tests/test-observables/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@jupyterlab/testutils/lib/babel.config');
1 change: 1 addition & 0 deletions tests/test-outputarea/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@jupyterlab/testutils/lib/babel.config');
1 change: 1 addition & 0 deletions tests/test-services/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@jupyterlab/testutils/lib/babel.config');
1 change: 1 addition & 0 deletions tests/test-statusbar/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@jupyterlab/testutils/lib/babel.config');
12 changes: 12 additions & 0 deletions testutils/src/babel.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
presets: [
[
'@babel/preset-env',
{
targets: {
node: 'current'
}
}
]
]
};
4 changes: 1 addition & 3 deletions testutils/src/jest-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import path = require('path');

module.exports = function(name: string, baseDir: string) {
return {
transform: {
'^.+\\.tsx?$': 'ts-jest'
},
preset: 'ts-jest/presets/js-with-babel',
moduleNameMapper: {
'\\.(css|less|sass|scss)$': 'identity-obj-proxy',
'\\.(gif|ttf|eot|svg)$': '@jupyterlab/testutils/lib/jest-file-mock.js'
Expand Down
1 change: 1 addition & 0 deletions testutils/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"compilerOptions": {
"outDir": "lib",
"rootDir": "src",
"module": "commonjs",
"types": ["node"]
},
"include": ["src/*"],
Expand Down
2 changes: 1 addition & 1 deletion tsconfigbase.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"esModuleInterop": true,
"incremental": true,
"jsx": "react",
"module": "commonjs",
"module": "esnext",
"moduleResolution": "node",
"noEmitOnError": true,
"noImplicitAny": true,
Expand Down

0 comments on commit 7844502

Please sign in to comment.