Skip to content

Commit 401d167

Browse files
committed
fix: adjust working karma tests + adjust yarn workspace to combat jest/mocha type conflicts
Signed-off-by: Kevin Viglucci <[email protected]>
1 parent f8371c2 commit 401d167

File tree

19 files changed

+5282
-2466
lines changed

19 files changed

+5282
-2466
lines changed

package.json

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,21 @@
22
"name": "rsocket-js",
33
"description": "A JavaScript implementation of the RSocket protocol (https://github.com/rsocket/rsocket).",
44
"private": true,
5-
"workspaces": [
6-
"packages/*"
7-
],
5+
"workspaces": {
6+
"packages": [
7+
"packages/*"
8+
],
9+
"nohoist": [
10+
"**/karma-*",
11+
"**/karma-*/**",
12+
"**/expect.js",
13+
"**/expect.js/**",
14+
"**/@types/jest",
15+
"**/@types/jest/**",
16+
"**/@types/mocha",
17+
"**/@types/mocha/**"
18+
]
19+
},
820
"scripts": {
921
"build": "lerna run build",
1022
"clean": "lerna run clean && rimraf -rf ./coverage",
@@ -15,7 +27,6 @@
1527
"lint:fix": "npm run lint -- --fix"
1628
},
1729
"devDependencies": {
18-
"@types/jest": "^27.0.3",
1930
"@types/node": "^17.0.5",
2031
"eslint": "~8.5.0",
2132
"eslint-plugin-import": "~2.25.3",
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Runnable example of unit testing Typescript on the fly in Karma with Istanbul coverage and Mocha
2+
3+
## Installation
4+
5+
```
6+
git clone https://github.com/monounity/karma-typescript.git
7+
cd karma-typescript/examples/mocha
8+
npm install
9+
```
10+
11+
## Running
12+
13+
```
14+
npm test
15+
```
16+
17+
The example unit tests should now run in Karma and html test coverage should be created in the folder `coverage` in the project root.
18+
19+
## Licensing
20+
21+
This software is licensed with the MIT license.
22+
23+
© 2016-2021 Erik Barke, Monounity

packages/rsocket-browser-tck/__tests__/sum.test.ts

Lines changed: 0 additions & 7 deletions
This file was deleted.

packages/rsocket-browser-tck/jest.config.ts

Lines changed: 0 additions & 17 deletions
This file was deleted.

packages/rsocket-browser-tck/karma-setup.js

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 8 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,20 @@
11
module.exports = function (config) {
22
config.set({
3-
plugins: ["karma-webpack", "karma-jasmine", "karma-chrome-launcher"],
3+
frameworks: ["mocha", "karma-typescript"],
44

5-
// base path that will be used to resolve all patterns (eg. files, exclude)
6-
basePath: "",
5+
files: [
6+
{ pattern: "node_modules/expect.js/index.js" },
7+
{ pattern: "src/**/*.ts" },
8+
],
79

8-
// frameworks to use
9-
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
10-
frameworks: ["jasmine"],
11-
12-
// list of files / patterns to load in the browser
13-
// Here I'm including all of the the Jest tests which are all under the __tests__ directory.
14-
// You may need to tweak this patter to find your test files/
15-
files: ["./karma-setup.js", "__tests__/**/*.ts"],
16-
17-
// preprocess matching files before serving them to the browser
18-
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
1910
preprocessors: {
20-
"./karma-setup.js": ["webpack"],
21-
// Use webpack to bundle our tests files
22-
"__tests__/**/*.ts": ["webpack"],
11+
"**/*.ts": ["karma-typescript"],
2312
},
2413

14+
reporters: ["dots", "karma-typescript"],
15+
2516
browsers: ["ChromeHeadless"],
2617

2718
singleRun: true,
28-
29-
webpack: {
30-
watch: false,
31-
module: {
32-
rules: [
33-
{
34-
test: /\.ts?$/,
35-
use: "ts-loader",
36-
exclude: /node_modules/,
37-
},
38-
],
39-
},
40-
resolve: {
41-
alias: {
42-
fs: false,
43-
process: false,
44-
},
45-
extensions: [".ts", ".js"],
46-
fallback: {
47-
// fs: false,
48-
buffer: require.resolve("buffer/"),
49-
util: require.resolve("util/"),
50-
assert: require.resolve("assert/"),
51-
stream: require.resolve("stream-browserify/"),
52-
constants: require.resolve("constants-browserify/"),
53-
path: require.resolve("path-browserify/"),
54-
},
55-
},
56-
},
5719
});
5820
};

0 commit comments

Comments
 (0)