-
Notifications
You must be signed in to change notification settings - Fork 0
test: add e2e tests #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
ca1702b
test: add e2e tests
mrazauskas f17de17
lint everything
mrazauskas b6d67de
add "files" to package.json
SimenB 456ff0f
run tests on ci
SimenB 00c37a7
Revert "add "files" to package.json"
SimenB b3a9967
use npmignore instead
SimenB 90afde5
rollback ts-eslint for node 10 support
SimenB 629e898
fix code issues
mrazauskas a5a08b8
add `graceful-fs`
mrazauskas 48e18c0
rename `resolveTypingsFile`
mrazauskas 5316c67
improved `resolveTypingsFile`
mrazauskas 7acb151
more improvements
mrazauskas 28d5955
normalize icons in snapshots
mrazauskas ba3e1e6
normalize slashes
mrazauskas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,3 @@ | ||
| node_modules/* | ||
| .idea/* | ||
| .vscode/* | ||
| node_modules | ||
| .DS_Store | ||
| *.log | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| e2e/ | ||
| .* | ||
| *.log | ||
| *.config.js |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| module.exports = { | ||
| presets: [ | ||
| ['@babel/preset-env', { targets: { node: 'current' } }], | ||
| '@babel/preset-typescript', | ||
| ], | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| /* eslint-disable no-unused-vars */ | ||
| declare const concat: { | ||
| (a: string, b: string): string; | ||
| (a: number, b: number): number; | ||
| }; | ||
|
|
||
| export default concat; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| module.exports = (a, b) => a + b; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| /** | ||
| * @type ./concat.d.ts | ||
| */ | ||
|
|
||
| import { expectType } from 'mlh-tsd'; | ||
| import concat from './concat'; | ||
|
|
||
| expectType<string>(concat('pre', 'fix')); | ||
| expectType<number>(concat(1, 2)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "jest": { | ||
| "runner": "../../../src/", | ||
| "testMatch": ["**/*.test.ts"] | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| /* eslint-disable no-unused-vars */ | ||
| declare const concat: { | ||
| (a: string, b: string): string; | ||
| (a: number, b: number): number; | ||
| }; | ||
|
|
||
| export default concat; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import { expectType } from 'mlh-tsd'; | ||
| import concat from '.'; | ||
|
|
||
| expectType<string>(concat('pre', 'fix')); | ||
| expectType<string>(concat(1, 2)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "jest": { | ||
| "runner": "../../../src/", | ||
| "testMatch": ["**/*.test.ts"] | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| /* eslint-disable no-unused-vars */ | ||
| declare const concat: { | ||
| (a: string, b: string): string; | ||
| (a: number, b: number): number; | ||
| }; | ||
|
|
||
| export default concat; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import { expectType } from 'mlh-tsd'; | ||
| import concat from '.'; | ||
|
|
||
| expectType<string>(concat('pre', 'fix')); | ||
| expectType<number>(concat(1, 2)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "jest": { | ||
| "runner": "../../../src/", | ||
| "testMatch": ["**/*.test.ts"] | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "types": "./types.d.ts", | ||
| "jest": { | ||
| "runner": "../../../src/", | ||
| "testMatch": ["**/*.test.ts"] | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| /* eslint-disable no-unused-vars */ | ||
| declare const concat: { | ||
| (a: string, b: string): string; | ||
| (a: number, b: number): number; | ||
| }; | ||
|
|
||
| export default concat; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import { expectType } from 'mlh-tsd'; | ||
| import concat from '.'; | ||
|
|
||
| expectType<string>(concat('pre', 'fix')); | ||
| expectType<number>(concat(1, 2)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| // Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
|
||
| exports[`reads \`@type\` comment in docblock 1`] = ` | ||
| "PASS e2e/__fixtures__/docblock/concat.test.ts | ||
| ✓ | ||
| Test Suites: 1 passed, 1 total | ||
| Tests: 2 passed, 2 total | ||
| Snapshots: 0 total | ||
| Time: | ||
| Ran all test suites. | ||
| " | ||
| `; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| // Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
|
||
| exports[`works with failing test 1`] = ` | ||
| "FAIL e2e/__fixtures__/failing/index.test.ts | ||
| ✓ | ||
| e2e/__fixtures__/failing/index.test.ts:5:19 - error - Argument of type 'number' is not assignable to parameter of type 'string'. | ||
| Test Suites: 1 failed, 1 total | ||
| Tests: 1 failed, 1 passed, 2 total | ||
| Snapshots: 0 total | ||
| Time: | ||
| Ran all test suites. | ||
| " | ||
| `; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| // Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
|
||
| exports[`works with passing test 1`] = ` | ||
| "PASS e2e/__fixtures__/passing/index.test.ts | ||
| ✓ | ||
| Test Suites: 1 passed, 1 total | ||
| Tests: 2 passed, 2 total | ||
| Snapshots: 0 total | ||
| Time: | ||
| Ran all test suites. | ||
| " | ||
| `; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| // Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
|
||
| exports[`reads \`types\` property in package.json 1`] = ` | ||
| "PASS e2e/__fixtures__/pkg-types/types.test.ts | ||
| ✓ | ||
| Test Suites: 1 passed, 1 total | ||
| Tests: 2 passed, 2 total | ||
| Snapshots: 0 total | ||
| Time: | ||
| Ran all test suites. | ||
| " | ||
| `; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import { expect, test } from '@jest/globals'; | ||
| import runJest from './runJest'; | ||
|
|
||
| test('reads `@type` comment in docblock', async () => { | ||
| expect(await runJest('docblock')).toMatchSnapshot(); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import { expect, test } from '@jest/globals'; | ||
| import runJest from './runJest'; | ||
|
|
||
| test('works with failing test', async () => { | ||
| expect(await runJest('failing')).toMatchSnapshot(); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import { expect, test } from '@jest/globals'; | ||
| import runJest from './runJest'; | ||
|
|
||
| test('works with passing test', async () => { | ||
| expect(await runJest('passing')).toMatchSnapshot(); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import { expect, test } from '@jest/globals'; | ||
| import runJest from './runJest'; | ||
|
|
||
| test('reads `types` property in package.json', async () => { | ||
| expect(await runJest('pkg-types')).toMatchSnapshot(); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import path from 'path'; | ||
| import execa from 'execa'; | ||
|
|
||
| const rootDir = path.join(__dirname, '..'); | ||
|
|
||
| const normalize = (output: string) => | ||
| output | ||
| .replace(/\(?\d*\.?\d+ ?m?s\b\)?/g, '') | ||
| .replace(/, estimated/g, '') | ||
| .replace(new RegExp(rootDir, 'g'), '/mocked-path-to-jest-runner-tsd') | ||
| .replace(/.*at .*\\n/g, 'mocked-stack-trace') | ||
| .replace(/(mocked-stack-trace)+/, ' at mocked-stack-trace') | ||
| .replace(new RegExp('\u00D7', 'g'), '\u2715') | ||
| .replace(new RegExp('\u221A', 'g'), '\u2713') | ||
| .replace(/\s+\n/g, '\n'); | ||
|
|
||
| const runJest = async (project: string, options = []) => { | ||
| const { stdout, stderr } = await execa( | ||
| 'jest', | ||
| [ | ||
| '--useStderr', | ||
| '--no-watchman', | ||
| '--no-cache', | ||
| '--projects', | ||
| path.join(__dirname, '__fixtures__', project), | ||
| ].concat(options), | ||
| { | ||
| env: { FORCE_COLOR: '0' }, | ||
| reject: false, | ||
| } | ||
| ); | ||
| return `${normalize(stderr)}\n${normalize(stdout)}`; | ||
| }; | ||
|
|
||
| export default runJest; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| module.exports = { | ||
| projects: [ | ||
| { | ||
| displayName: 'e2e', | ||
| testMatch: ['<rootDir>/e2e/*.test.ts'], | ||
| }, | ||
| ], | ||
| testTimeout: 20000, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,19 +10,27 @@ | |
| "Saurabh Agarwala <[email protected]>" | ||
| ], | ||
| "scripts": { | ||
| "lint": "eslint ." | ||
| "lint": "eslint .", | ||
| "test": "jest" | ||
| }, | ||
| "dependencies": { | ||
| "create-jest-runner": "^0.6.0", | ||
| "jest-docblock": "^26.0.0", | ||
| "create-jest-runner": "^0.9.0", | ||
| "graceful-fs": "^4.2.8", | ||
| "jest-docblock": "^27.0.6", | ||
| "mlh-tsd": "^0.14.1" | ||
| }, | ||
| "devDependencies": { | ||
| "@typescript-eslint/eslint-plugin": "^5.0.0", | ||
| "@typescript-eslint/parser": "^5.0.0", | ||
| "@babel/core": "^7.15.8", | ||
| "@babel/preset-env": "^7.15.8", | ||
| "@babel/preset-typescript": "^7.15.0", | ||
| "@typescript-eslint/eslint-plugin": "^4.33.0", | ||
| "@typescript-eslint/parser": "^4.33.0", | ||
| "babel-jest": "^27.2.5", | ||
| "eslint": "^7.32.0", | ||
| "eslint-config-prettier": "^8.3.0", | ||
| "eslint-plugin-prettier": "^3.4.1", | ||
| "execa": "^5.1.1", | ||
| "jest": "^27.2.5", | ||
| "prettier": "^2.4.1", | ||
| "typescript": "^4.4.4" | ||
| }, | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.