1
0
Fork 0

Add working Jest & TypeScript config

- Jest now uses ts-jest for transforms
- TypeScript compilation via `lerna run tsc`
pull/1/head
Jonathan Clem 2019-04-19 15:15:34 -04:00
parent 97bc7918f4
commit f026c43b81
No known key found for this signature in database
GPG Key ID: 48C5B22E9FD6E80F
10 changed files with 124 additions and 27 deletions

12
jest.config.js Normal file
View File

@ -0,0 +1,12 @@
module.exports = {
clearMocks: true,
moduleFileExtensions: ['js', 'ts'],
roots: ['<rootDir>/packages'],
testEnvironment: 'node',
testMatch: ['**/__tests__/*.test.ts'],
testRunner: 'jest-circus/runner',
transform: {
'^.+\\.ts$': 'ts-jest'
},
verbose: true
}

70
package-lock.json generated
View File

@ -1326,6 +1326,27 @@
"integrity": "sha512-eAtOAFZefEnfJiRFQBGw1eYqa5GTLCZ1y86N0XSI/D6EB+E8z6VPV/UL7Gi5UEclFqoQk+6NRqEDsfmDLXn8sg==",
"dev": true
},
"@types/jest": {
"version": "24.0.11",
"resolved": "https://registry.npmjs.org/@types/jest/-/jest-24.0.11.tgz",
"integrity": "sha512-2kLuPC5FDnWIDvaJBzsGTBQaBbnDweznicvK7UGYzlIJP4RJR2a4A/ByLUXEyEgag6jz8eHdlWExGDtH3EYUXQ==",
"dev": true,
"requires": {
"@types/jest-diff": "*"
}
},
"@types/jest-diff": {
"version": "20.0.1",
"resolved": "https://registry.npmjs.org/@types/jest-diff/-/jest-diff-20.0.1.tgz",
"integrity": "sha512-yALhelO3i0hqZwhjtcr6dYyaLoCHbAMshwtj6cGxTvHZAKXHsYGdff6E8EPw3xLKY0ELUTQ69Q1rQiJENnccMA==",
"dev": true
},
"@types/node": {
"version": "11.13.5",
"resolved": "https://registry.npmjs.org/@types/node/-/node-11.13.5.tgz",
"integrity": "sha512-/OMMBnjVtDuwX1tg2pkYVSqRIDSmNTnvVvmvP/2xiMAAWf4a5+JozrApCrO4WCAILmXVxfNoQ3E+0HJbNpFVGg==",
"dev": true
},
"@types/stack-utils": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-1.0.1.tgz",
@ -1883,6 +1904,15 @@
}
}
},
"bs-logger": {
"version": "0.2.6",
"resolved": "https://registry.npmjs.org/bs-logger/-/bs-logger-0.2.6.tgz",
"integrity": "sha512-pd8DCoxmbgc7hyPKOvxtqNcjYoOsABPQdcCUjGp3d42VR2CX1ORhk2A87oqqu5R1kk+76nsxZupkmyd+MVtCog==",
"dev": true,
"requires": {
"fast-json-stable-stringify": "2.x"
}
},
"bser": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/bser/-/bser-2.0.0.tgz",
@ -6045,6 +6075,12 @@
"pify": "^3.0.0"
}
},
"make-error": {
"version": "1.3.5",
"resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.5.tgz",
"integrity": "sha512-c3sIjNUow0+8swNwVpqoH4YCShKNFkMaw6oH1mNS2haDZQqkeZFlHS3dhoeEbKKmJB4vXpJucU6oH75aDYeE9g==",
"dev": true
},
"make-fetch-happen": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/make-fetch-happen/-/make-fetch-happen-4.0.1.tgz",
@ -8370,6 +8406,34 @@
"integrity": "sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM=",
"dev": true
},
"ts-jest": {
"version": "24.0.2",
"resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-24.0.2.tgz",
"integrity": "sha512-h6ZCZiA1EQgjczxq+uGLXQlNgeg02WWJBbeT8j6nyIBRQdglqbvzDoHahTEIiS6Eor6x8mK6PfZ7brQ9Q6tzHw==",
"dev": true,
"requires": {
"bs-logger": "0.x",
"buffer-from": "1.x",
"fast-json-stable-stringify": "2.x",
"json5": "2.x",
"make-error": "1.x",
"mkdirp": "0.x",
"resolve": "1.x",
"semver": "^5.5",
"yargs-parser": "10.x"
},
"dependencies": {
"yargs-parser": {
"version": "10.1.0",
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-10.1.0.tgz",
"integrity": "sha512-VCIyR1wJoEBZUqk5PA+oOBF6ypbwh5aNB3I50guxAL/quggdfs4TtNHQrSazFA3fYZ+tEqfs0zIGlv0c/rgjbQ==",
"dev": true,
"requires": {
"camelcase": "^4.1.0"
}
}
}
},
"tslib": {
"version": "1.9.3",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz",
@ -8406,6 +8470,12 @@
"integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=",
"dev": true
},
"typescript": {
"version": "3.4.4",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.4.4.tgz",
"integrity": "sha512-xt5RsIRCEaf6+j9AyOBgvVuAec0i92rgCaS3S+UVf5Z/vF2Hvtsw08wtUTJqp4djwznoAgjSxeCcU4r+CcDBJA==",
"dev": true
},
"uglify-js": {
"version": "3.5.5",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.5.5.tgz",

View File

@ -4,18 +4,13 @@
"scripts": {
"test": "jest"
},
"jest": {
"clearMocks": true,
"roots": [
"<rootDir>/packages"
],
"testEnvironment": "node",
"testRunner": "jest-circus/runner",
"verbose": true
},
"devDependencies": {
"@types/jest": "^24.0.11",
"@types/node": "^11.13.5",
"jest": "^24.7.1",
"jest-circus": "^24.7.1",
"lerna": "^3.13.3"
"lerna": "^3.13.3",
"ts-jest": "^24.0.2",
"typescript": "^3.4.4"
}
}

View File

@ -1,9 +0,0 @@
'use strict';
// const github = require('..');
describe('@actions/github', () => {
it('needs tests', () => {
});
});

View File

@ -0,0 +1,7 @@
import { github } from '../src/github';
describe('@actions/github', () => {
it('needs tests', () => {
expect(github()).toBe(true)
});
});

View File

@ -1,7 +0,0 @@
'use strict';
module.exports = github;
function github() {
// TODO
}

View File

@ -24,7 +24,8 @@
"url": "git+https://github.com/actions/toolkit.git"
},
"scripts": {
"test": "echo \"Error: run tests from root\" && exit 1"
"test": "echo \"Error: run tests from root\" && exit 1",
"tsc": "tsc"
},
"bugs": {
"url": "https://github.com/actions/toolkit/issues"

View File

@ -0,0 +1,3 @@
export function github() {
return true
}

View File

@ -0,0 +1,11 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"baseUrl": "./",
"outDir": "./lib",
"rootDir": "./src"
},
"include": [
"./src"
]
}

14
tsconfig.json Normal file
View File

@ -0,0 +1,14 @@
{
"compilerOptions": {
"module": "commonjs",
"strict": true,
"declaration": true,
"target": "es6",
"sourceMap": true,
"lib": ["es6"]
},
"exclude": [
"node_modules",
"**/*.test.ts"
]
}