Skip to content

Commit 0a11225

Browse files
authored
test: add e2e tests (#19)
1 parent f0e14fb commit 0a11225

30 files changed

+3080
-127
lines changed

.github/workflows/nodejs.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,23 @@ on:
1111
- next
1212

1313
jobs:
14+
prepare-yarn-cache:
15+
name: Prepare yarn cache
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- uses: actions/checkout@v2
20+
21+
- uses: actions/setup-node@v2
22+
with:
23+
node-version: 14.x
24+
cache: yarn
25+
26+
- name: Validate cache
27+
run: yarn
28+
1429
lint:
30+
needs: prepare-yarn-cache
1531
runs-on: ubuntu-latest
1632
steps:
1733
- uses: actions/checkout@v2
@@ -23,3 +39,45 @@ jobs:
2339
run: yarn
2440
- name: run ESLint
2541
run: yarn lint
42+
43+
test-node:
44+
name: Test on Node.js v${{ matrix.node-version }}
45+
needs: prepare-yarn-cache
46+
strategy:
47+
fail-fast: false
48+
matrix:
49+
node-version: [10.x, 12.x, 14.x, 16.x]
50+
runs-on: ubuntu-latest
51+
52+
steps:
53+
- uses: actions/checkout@v2
54+
- name: Use Node.js ${{ matrix.node-version }}
55+
uses: actions/setup-node@v2
56+
with:
57+
node-version: ${{ matrix.node-version }}
58+
cache: yarn
59+
- name:
60+
install
61+
run: yarn
62+
- name: run tests
63+
run: yarn test
64+
65+
test-os:
66+
name: Test on ${{ matrix.os }} using Node.js LTS
67+
needs: prepare-yarn-cache
68+
strategy:
69+
fail-fast: false
70+
matrix:
71+
os: [ubuntu-latest, windows-latest, macOS-latest]
72+
runs-on: ${{ matrix.os }}
73+
74+
steps:
75+
- uses: actions/checkout@v2
76+
- uses: actions/setup-node@v2
77+
with:
78+
node-version: 14.x
79+
cache: yarn
80+
- name: install
81+
run: yarn
82+
- name: run tests
83+
run: yarn test

.gitignore

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
node_modules/*
2-
.idea/*
3-
.vscode/*
1+
node_modules
2+
.DS_Store
43
*.log
5-

.npmignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
e2e/
2+
.*
3+
*.log
4+
*.config.js

babel.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
presets: [
3+
['@babel/preset-env', { targets: { node: 'current' } }],
4+
'@babel/preset-typescript',
5+
],
6+
};
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/* eslint-disable no-unused-vars */
2+
declare const concat: {
3+
(a: string, b: string): string;
4+
(a: number, b: number): number;
5+
};
6+
7+
export default concat;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = (a, b) => a + b;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* @type ./concat.d.ts
3+
*/
4+
5+
import { expectType } from 'mlh-tsd';
6+
import concat from './concat';
7+
8+
expectType<string>(concat('pre', 'fix'));
9+
expectType<number>(concat(1, 2));
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"jest": {
3+
"runner": "../../../src/",
4+
"testMatch": ["**/*.test.ts"]
5+
}
6+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/* eslint-disable no-unused-vars */
2+
declare const concat: {
3+
(a: string, b: string): string;
4+
(a: number, b: number): number;
5+
};
6+
7+
export default concat;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { expectType } from 'mlh-tsd';
2+
import concat from '.';
3+
4+
expectType<string>(concat('pre', 'fix'));
5+
expectType<string>(concat(1, 2));

0 commit comments

Comments
 (0)