Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

Commit

Permalink
Merge pull request #462 from jtpio/tests-jupyter-server
Browse files Browse the repository at this point in the history
Switch to JupyterServer from @jupyterlab/testutils
  • Loading branch information
afshin authored Jun 5, 2020
2 parents 34dff58 + 16acd32 commit ac07a78
Show file tree
Hide file tree
Showing 11 changed files with 99 additions and 68 deletions.
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,5 @@ jobs:
source "$CONDA/etc/profile.d/conda.sh"
conda activate jupyterlab-debugger
export XEUS_LOG=1
jlpm run build:test
jlpm run test
File renamed without changes.
16 changes: 5 additions & 11 deletions tests/jest.config.js → jest.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const func = require('@jupyterlab/testutils/lib/jest-config');
const upstream = func('@jupyterlab/debugger', __dirname);
const upstream = func(__dirname);

let local = {
preset: 'ts-jest/presets/js-with-babel',
transformIgnorePatterns: ['/node_modules/(?!(@jupyterlab/.*)/)'],
globals: {
'ts-jest': {
tsConfig: './tsconfig.json'
tsConfig: './tsconfig.test.json'
}
},
transform: {
Expand All @@ -15,14 +15,8 @@ let local = {
}
};

[
'moduleFileExtensions',
'moduleNameMapper',
'reporters',
'setupFilesAfterEnv',
'setupFiles'
].forEach(option => {
local[option] = upstream[option];
Object.keys(local).forEach(option => {
upstream[option] = local[option];
});

module.exports = local;
module.exports = upstream;
16 changes: 10 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
},
"scripts": {
"build": "tsc -b",
"clean": "rimraf lib && rimraf tsconfig.tsbuildinfo && rimraf tests/build",
"build:test": "tsc --build tsconfig.test.json",
"clean": "rimraf lib && rimraf tsconfig.tsbuildinfo && rimraf tsconfig.test.tsbuildinfo && rimraf tests/build",
"docs": "typedoc --options tdoptions.json --theme ../../typedoc-theme src",
"eslint": "eslint . --ext .ts,.tsx,.js,.jsx --fix",
"eslint:check": "eslint . --ext .ts,.tsx,.js,.jsx",
Expand All @@ -45,7 +46,10 @@
"prepublishOnly": "npm run build",
"prettier": "prettier --write '**/*{.ts,.tsx,.js,.jsx,.css,.json,.md}'",
"prettier:check": "prettier --list-different '**/*{.ts,.tsx,.js,.jsx,.css,.json,.md}'",
"test": "python tests/run-test.py",
"test": "jest",
"test:cov": "jest --collect-coverage",
"test:debug": "node --inspect-brk node_modules/.bin/jest --runInBand",
"test:debug:watch": "node --inspect-brk node_modules/.bin/jest --runInBand --watch",
"watch": "tsc -b --watch"
},
"dependencies": {
Expand All @@ -71,9 +75,9 @@
"vscode-debugprotocol": "^1.37.0"
},
"devDependencies": {
"@babel/core": "^7.5.5",
"@babel/preset-env": "^7.7.6",
"@jupyterlab/testutils": "^2.0.0",
"@babel/core": "^7.10.2",
"@babel/preset-env": "^7.10.2",
"@jupyterlab/testutils": "^2.2.0-alpha.0",
"@types/codemirror": "0.0.76",
"@types/jest": "^24.0.17",
"@types/murmurhash-js": "1.0.3",
Expand All @@ -87,7 +91,7 @@
"eslint-plugin-prettier": "^3.1.1",
"eslint-plugin-react": "^7.19.0",
"husky": "^3.1.0",
"jest": "^26.0.1",
"jest": "^25",
"jest-junit": "^10.0.0",
"jest-raw-loader": "^1.0.1",
"jest-summary-reporter": "^0.0.2",
Expand Down
17 changes: 15 additions & 2 deletions tests/src/debugger.spec.ts → test/debugger.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,30 @@ import {
CodeMirrorMimeTypeService
} from '@jupyterlab/codemirror';

import { JupyterServer } from '@jupyterlab/testutils';

import { CommandRegistry } from '@lumino/commands';

import { Debugger } from '../../lib/debugger';
import { Debugger } from '../src/debugger';

import { DebuggerService } from '../../lib/service';
import { DebuggerService } from '../src/service';

/**
* A test sidebar.
*/
class TestSidebar extends Debugger.Sidebar {}

const server = new JupyterServer();

beforeAll(async () => {
jest.setTimeout(20000);
await server.start();
});

afterAll(async () => {
await server.shutdown();
});

describe('Debugger', () => {
const service = new DebuggerService();
const registry = new CommandRegistry();
Expand Down
25 changes: 20 additions & 5 deletions tests/src/service.spec.ts → test/service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
import { Session } from '@jupyterlab/services';

import { createSession, signalToPromise } from '@jupyterlab/testutils';
import {
createSession,
signalToPromise,
JupyterServer
} from '@jupyterlab/testutils';

import { UUID } from '@lumino/coreutils';

import { DebuggerModel } from '../../lib/model';
import { DebuggerModel } from '../src/model';

import { DebuggerService } from '../../lib/service';
import { DebuggerService } from '../src/service';

import { DebugSession } from '../../lib/session';
import { DebugSession } from '../src/session';

import { IDebugger } from '../../lib/tokens';
import { IDebugger } from '../src/tokens';

const server = new JupyterServer();

beforeAll(async () => {
jest.setTimeout(20000);
await server.start();
});

afterAll(async () => {
await server.shutdown();
});

describe('Debugging support', () => {
const service = new DebuggerService();
Expand Down
21 changes: 18 additions & 3 deletions tests/src/session.spec.ts → test/session.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,32 @@

import { Session } from '@jupyterlab/services';

import { createSession, signalToPromises } from '@jupyterlab/testutils';
import {
createSession,
signalToPromises,
JupyterServer
} from '@jupyterlab/testutils';

import { find } from '@lumino/algorithm';

import { PromiseDelegate, UUID } from '@lumino/coreutils';

import { DebugProtocol } from 'vscode-debugprotocol';

import { IDebugger } from '../../lib/tokens';
import { IDebugger } from '../src/tokens';

import { DebugSession } from '../../lib/session';
import { DebugSession } from '../src/session';

const server = new JupyterServer();

beforeAll(async () => {
jest.setTimeout(20000);
await server.start();
});

afterAll(async () => {
await server.shutdown();
});

describe('DebugSession', () => {
let connection: Session.ISessionConnection;
Expand Down
30 changes: 0 additions & 30 deletions tests/run-test.py

This file was deleted.

10 changes: 0 additions & 10 deletions tests/tsconfig.json

This file was deleted.

2 changes: 1 addition & 1 deletion tsconfig.eslint.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "./tsconfig",
"include": ["src/**/*", "tests/**/*", "*.js"],
"include": ["src/**/*", "test/**/*", "*.js"],
"types": ["jest"]
}
29 changes: 29 additions & 0 deletions tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"compilerOptions": {
"declaration": true,
"noEmitOnError": true,
"noUnusedLocals": true,
"module": "commonjs",
"moduleResolution": "node",
"target": "es2015",
"outDir": "lib",
"lib": [
"es2015",
"es2015.collection",
"dom",
"es2015.iterable",
"es2017.object"
],
"types": ["jest"],
"jsx": "react",
"resolveJsonModule": true,
"esModuleInterop": true,
"skipLibCheck": true
},
"include": ["src/**/*", "test/**/*"],
"references": [
{
"path": "."
}
]
}

0 comments on commit ac07a78

Please sign in to comment.