Skip to content

Commit

Permalink
Migrate tests to TypeScript (#167)
Browse files Browse the repository at this point in the history
* move tests to typescript

* move mocks dir to root
  • Loading branch information
shanejonas authored May 6, 2021
1 parent 1dc6beb commit 1a668f1
Show file tree
Hide file tree
Showing 10 changed files with 417 additions and 364 deletions.
6 changes: 3 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ module.exports = {
// },
// },
setupFilesAfterEnv: ['./jest.setup.js'],
moduleFileExtensions: ['js'],
silent: true,
testEnvironment: 'jsdom',
testRegex: ['\\.test\\.js$'],
silent: true,
preset: 'ts-jest',
testRegex: ['\\.test\\.ts$'],
testTimeout: 5000,
};
21 changes: 21 additions & 0 deletions mocks/DuplexStream.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Duplex } from 'stream';

export default class DuplexStream extends Duplex {
constructor() {
super({
objectMode: true,
});
}

pushToSubstream(name: string, data: unknown) {
this.push({ name, data });
}

_write(_data: unknown, _encoding: string, callback: any) {
callback();
}

_read() {
return undefined;
}
}
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"scripts": {
"build": "tsc --project .",
"test": "yarn build && jest",
"test": "jest",
"coverage": "jest --coverage",
"lint:eslint": "eslint . --cache --ext js,ts",
"lint:misc": "prettier '**/*.json' '**/*.md' '**/*.yml' --single-quote --ignore-path .gitignore",
Expand Down Expand Up @@ -55,7 +55,7 @@
"@metamask/eslint-config-jest": "^6.0.0",
"@metamask/eslint-config-nodejs": "^6.0.0",
"@metamask/eslint-config-typescript": "^6.0.0",
"@types/jest": "^26.0.5",
"@types/jest": "^26.0.23",
"@types/node": "^14.14.14",
"@types/pump": "^1.1.0",
"@types/readable-stream": "^2.3.9",
Expand All @@ -71,6 +71,7 @@
"jest": "^26.6.3",
"jest-chrome": "^0.7.1",
"prettier": "^2.2.1",
"typescript": "^4.1.3"
"ts-jest": "^26.5.6",
"typescript": "^4.2.4"
}
}
Loading

0 comments on commit 1a668f1

Please sign in to comment.