From f026c43b81bc7e3cbc81d156bfaefaaa305fdf8f Mon Sep 17 00:00:00 2001 From: Jonathan Clem Date: Fri, 19 Apr 2019 15:15:34 -0400 Subject: [PATCH] Add working Jest & TypeScript config - Jest now uses ts-jest for transforms - TypeScript compilation via `lerna run tsc` --- jest.config.js | 12 ++++ package-lock.json | 70 ++++++++++++++++++++++++ package.json | 15 ++--- packages/github/__tests__/github.test.js | 9 --- packages/github/__tests__/github.test.ts | 7 +++ packages/github/lib/github.js | 7 --- packages/github/package.json | 3 +- packages/github/src/github.ts | 3 + packages/github/tsconfig.json | 11 ++++ tsconfig.json | 14 +++++ 10 files changed, 124 insertions(+), 27 deletions(-) create mode 100644 jest.config.js delete mode 100644 packages/github/__tests__/github.test.js create mode 100644 packages/github/__tests__/github.test.ts delete mode 100644 packages/github/lib/github.js create mode 100644 packages/github/src/github.ts create mode 100644 packages/github/tsconfig.json create mode 100644 tsconfig.json diff --git a/jest.config.js b/jest.config.js new file mode 100644 index 00000000..df845a4c --- /dev/null +++ b/jest.config.js @@ -0,0 +1,12 @@ +module.exports = { + clearMocks: true, + moduleFileExtensions: ['js', 'ts'], + roots: ['/packages'], + testEnvironment: 'node', + testMatch: ['**/__tests__/*.test.ts'], + testRunner: 'jest-circus/runner', + transform: { + '^.+\\.ts$': 'ts-jest' + }, + verbose: true +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 5f2300a1..e83d491b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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", diff --git a/package.json b/package.json index 80f765d5..5f542cf3 100644 --- a/package.json +++ b/package.json @@ -4,18 +4,13 @@ "scripts": { "test": "jest" }, - "jest": { - "clearMocks": true, - "roots": [ - "/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" } } diff --git a/packages/github/__tests__/github.test.js b/packages/github/__tests__/github.test.js deleted file mode 100644 index a5853960..00000000 --- a/packages/github/__tests__/github.test.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -// const github = require('..'); - -describe('@actions/github', () => { - it('needs tests', () => { - - }); -}); diff --git a/packages/github/__tests__/github.test.ts b/packages/github/__tests__/github.test.ts new file mode 100644 index 00000000..3a99860b --- /dev/null +++ b/packages/github/__tests__/github.test.ts @@ -0,0 +1,7 @@ +import { github } from '../src/github'; + +describe('@actions/github', () => { + it('needs tests', () => { + expect(github()).toBe(true) + }); +}); \ No newline at end of file diff --git a/packages/github/lib/github.js b/packages/github/lib/github.js deleted file mode 100644 index 262b98a6..00000000 --- a/packages/github/lib/github.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -module.exports = github; - -function github() { - // TODO -} diff --git a/packages/github/package.json b/packages/github/package.json index c2dd0c96..af096ee4 100644 --- a/packages/github/package.json +++ b/packages/github/package.json @@ -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" diff --git a/packages/github/src/github.ts b/packages/github/src/github.ts new file mode 100644 index 00000000..a34eacdc --- /dev/null +++ b/packages/github/src/github.ts @@ -0,0 +1,3 @@ +export function github() { + return true +} diff --git a/packages/github/tsconfig.json b/packages/github/tsconfig.json new file mode 100644 index 00000000..a8b812a6 --- /dev/null +++ b/packages/github/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "baseUrl": "./", + "outDir": "./lib", + "rootDir": "./src" + }, + "include": [ + "./src" + ] +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 00000000..80c954ed --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,14 @@ +{ + "compilerOptions": { + "module": "commonjs", + "strict": true, + "declaration": true, + "target": "es6", + "sourceMap": true, + "lib": ["es6"] + }, + "exclude": [ + "node_modules", + "**/*.test.ts" + ] +} \ No newline at end of file