Bladeren bron

Switch to JupyterServer from @jupyterlab/testutils

Jeremy Tuloup 5 jaren geleden
bovenliggende
commit
63b8370600
10 gewijzigde bestanden met toevoegingen van 91 en 37 verwijderingen
  1. 1 0
      .github/workflows/tests.yml
  2. 0 0
      babel.config.js
  3. 5 11
      jest.config.js
  4. 5 5
      package.json
  5. 14 2
      test/debugger.spec.ts
  6. 19 5
      test/service.spec.ts
  7. 17 3
      test/session.spec.ts
  8. 0 10
      tests/tsconfig.json
  9. 1 1
      tsconfig.eslint.json
  10. 29 0
      tsconfig.test.json

+ 1 - 0
.github/workflows/tests.yml

@@ -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

+ 0 - 0
tests/babel.config.js → babel.config.js


+ 5 - 11
tests/jest.config.js → jest.config.js

@@ -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: {
@@ -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;

+ 5 - 5
package.json

@@ -36,8 +36,8 @@
   },
   "scripts": {
     "build": "tsc -b",
-    "build:test": "tsc --build tests/tsconfig.json",
-    "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",
@@ -75,8 +75,8 @@
     "vscode-debugprotocol": "^1.37.0"
   },
   "devDependencies": {
-    "@babel/core": "^7.5.5",
-    "@babel/preset-env": "^7.7.6",
+    "@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",
@@ -91,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",

+ 14 - 2
tests/src/debugger.spec.ts → test/debugger.spec.ts

@@ -3,17 +3,29 @@ 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 () => {
+  await server.start();
+});
+
+afterAll(async () => {
+  await server.shutdown();
+});
+
 describe('Debugger', () => {
   const service = new DebuggerService();
   const registry = new CommandRegistry();

+ 19 - 5
tests/src/service.spec.ts → test/service.spec.ts

@@ -1,16 +1,30 @@
 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 () => {
+  await server.start();
+});
+
+afterAll(async () => {
+  await server.shutdown();
+});
 
 describe('Debugging support', () => {
   const service = new DebuggerService();

+ 17 - 3
tests/src/session.spec.ts → test/session.spec.ts

@@ -3,7 +3,11 @@
 
 import { Session } from '@jupyterlab/services';
 
-import { createSession, signalToPromises } from '@jupyterlab/testutils';
+import {
+  createSession,
+  signalToPromises,
+  JupyterServer
+} from '@jupyterlab/testutils';
 
 import { find } from '@lumino/algorithm';
 
@@ -11,9 +15,19 @@ 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 () => {
+  await server.start();
+});
+
+afterAll(async () => {
+  await server.shutdown();
+});
 
 describe('DebugSession', () => {
   let connection: Session.ISessionConnection;

+ 0 - 10
tests/tsconfig.json

@@ -1,10 +0,0 @@
-{
-  "extends": "../tsconfig.json",
-  "compilerOptions": {
-    "outDir": "build",
-    "rootDir": "src",
-    "target": "es2017",
-    "types": ["jest"]
-  },
-  "include": ["src/**/*"]
-}

+ 1 - 1
tsconfig.eslint.json

@@ -1,5 +1,5 @@
 {
   "extends": "./tsconfig",
-  "include": ["src/**/*", "tests/**/*", "*.js"],
+  "include": ["src/**/*", "test/**/*", "*.js"],
   "types": ["jest"]
 }

+ 29 - 0
tsconfig.test.json

@@ -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": "."
+    }
+  ]
+}