Browse Source

Finish test template cleanup

Steven Silvester 5 years ago
parent
commit
06a3922c8d

+ 0 - 0
buildutils/template/launch.json → buildutils/template/.vscode/launch.json


+ 6 - 1
buildutils/template/tsconfig.test.json

@@ -1,4 +1,9 @@
 {
   "extends": "../../tsconfigbase.test",
-  "include": ["src/*", "test/*"]
+  "include": ["src/*", "test/*"],
+  "references": [
+    {
+      "path": "../../testutils"
+    }
+  ]
 }

+ 2 - 0
dev_mode/package.json

@@ -114,6 +114,7 @@
     "@jupyterlab/filebrowser-extension": "~2.1.0",
     "@jupyterlab/fileeditor": "~2.1.0",
     "@jupyterlab/fileeditor-extension": "~2.1.0",
+    "@jupyterlab/foo": "~2.1.0",
     "@jupyterlab/help-extension": "~2.1.0",
     "@jupyterlab/htmlviewer": "~2.1.0",
     "@jupyterlab/htmlviewer-extension": "~2.1.0",
@@ -296,6 +297,7 @@
       "@jupyterlab/filebrowser-extension": "../packages/filebrowser-extension",
       "@jupyterlab/fileeditor": "../packages/fileeditor",
       "@jupyterlab/fileeditor-extension": "../packages/fileeditor-extension",
+      "@jupyterlab/foo": "../packages/foo",
       "@jupyterlab/help-extension": "../packages/help-extension",
       "@jupyterlab/htmlviewer": "../packages/htmlviewer",
       "@jupyterlab/htmlviewer-extension": "../packages/htmlviewer-extension",

+ 1 - 0
packages/metapackage/package.json

@@ -60,6 +60,7 @@
     "@jupyterlab/filebrowser-extension": "^2.1.0",
     "@jupyterlab/fileeditor": "^2.1.0",
     "@jupyterlab/fileeditor-extension": "^2.1.0",
+    "@jupyterlab/foo": "^2.1.0",
     "@jupyterlab/help-extension": "^2.1.0",
     "@jupyterlab/htmlviewer": "^2.1.0",
     "@jupyterlab/htmlviewer-extension": "^2.1.0",

+ 3 - 0
packages/metapackage/tsconfig.json

@@ -248,6 +248,9 @@
     },
     {
       "path": "../vega5-extension"
+    },
+    {
+      "path": "../foo"
     }
   ]
 }

+ 1 - 1
testutils/package.json

@@ -26,7 +26,7 @@
   },
   "scripts": {
     "build": "tsc -b",
-    "clean": "rimraf lib",
+    "clean": "rimraf lib && rimraf tsconfig.tsbuildinfo",
     "prepublishOnly": "npm run build",
     "watch": "tsc --watch"
   },

+ 0 - 27
testutils/src/jest-config-new.ts

@@ -1,27 +0,0 @@
-import path = require('path');
-
-module.exports = function(baseDir: string) {
-  return {
-    preset: 'ts-jest/presets/js-with-babel',
-    moduleNameMapper: {
-      '\\.(css|less|sass|scss)$': 'identity-obj-proxy',
-      '\\.(gif|ttf|eot)$': '@jupyterlab/testutils/lib/jest-file-mock.js'
-    },
-    transform: {
-      '\\.svg$': 'jest-raw-loader',
-      '^.+\\.md?$': 'markdown-loader-jest'
-    },
-    setupFiles: ['@jupyterlab/testutils/lib/jest-shim.js'],
-    testPathIgnorePatterns: ['/lib/', '/node_modules/'],
-    moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
-    reporters: ['default', 'jest-junit'],
-    coverageReporters: ['json', 'lcov', 'text', 'html'],
-    coverageDirectory: path.join(baseDir, 'coverage'),
-    testRegex: '/test/.*.spec.ts[x]?$',
-    globals: {
-      'ts-jest': {
-        tsConfig: `./tsconfig.test.json`
-      }
-    }
-  };
-};

+ 6 - 11
testutils/src/jest-config.ts

@@ -1,6 +1,6 @@
 import path = require('path');
 
-module.exports = function(name: string, baseDir: string) {
+module.exports = function(baseDir: string) {
   return {
     preset: 'ts-jest/presets/js-with-babel',
     moduleNameMapper: {
@@ -8,24 +8,19 @@ module.exports = function(name: string, baseDir: string) {
       '\\.(gif|ttf|eot)$': '@jupyterlab/testutils/lib/jest-file-mock.js'
     },
     transform: {
-      '\\.svg$': 'jest-raw-loader'
+      '\\.svg$': 'jest-raw-loader',
+      '^.+\\.md?$': 'markdown-loader-jest'
     },
     setupFiles: ['@jupyterlab/testutils/lib/jest-shim.js'],
-    testPathIgnorePatterns: ['/dev_mode/', '/lib/', '/node_modules/'],
+    testPathIgnorePatterns: ['/lib/', '/node_modules/'],
     moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
-    rootDir: path.resolve(path.join(baseDir, '..', '..')),
     reporters: ['default', 'jest-junit'],
-    collectCoverageFrom: [
-      `packages/${name}/src/**.{ts,tsx}`,
-      `!packages/${name}/src/*.d.ts`
-    ],
-    testTimeout: 20000,
     coverageReporters: ['json', 'lcov', 'text', 'html'],
     coverageDirectory: path.join(baseDir, 'coverage'),
-    testRegex: `tests\/test-${name}\/src\/.*\.spec\.tsx?$`,
+    testRegex: '/test/.*.spec.ts[x]?$',
     globals: {
       'ts-jest': {
-        tsConfig: `./tsconfig.json`
+        tsConfig: `./tsconfig.test.json`
       }
     }
   };