Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.

Commit a1c1100

Browse files
committed
Replace 'dtslint' with TS integration test
1 parent 7de2e96 commit a1c1100

File tree

12 files changed

+117
-802
lines changed

12 files changed

+117
-802
lines changed

.eslintrc.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,11 +477,11 @@ rules:
477477
wrap-regex: off
478478
yield-star-spacing: off
479479

480+
ignorePatterns: 'integrationTests/ts/*.ts'
480481
overrides:
481482
- files: '**/*.ts'
482483
parser: '@typescript-eslint/parser'
483484
parserOptions:
484-
tsconfigRootDir: './types/'
485485
project: ['tsconfig.json']
486486
plugins:
487487
- '@typescript-eslint'
@@ -633,6 +633,16 @@ overrides:
633633
import/no-extraneous-dependencies: [error, { devDependencies: true }]
634634
import/no-nodejs-modules: off
635635
no-sync: off
636+
- files: 'integrationTests/**'
637+
parserOptions:
638+
sourceType: script
639+
rules:
640+
node/no-unpublished-import: off
641+
node/no-unpublished-require: off
642+
node/no-sync: off
643+
import/no-extraneous-dependencies: [error, { devDependencies: true }]
644+
import/no-nodejs-modules: off
645+
no-console: off
636646
- files: 'resources/**'
637647
parserOptions:
638648
sourceType: script

.github/workflows/ci.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,29 @@ jobs:
3535
- name: Lint Flow
3636
run: npm run check
3737

38+
integrationTests:
39+
name: Run integration tests
40+
runs-on: ubuntu-latest
41+
steps:
42+
- name: Checkout repo
43+
uses: actions/checkout@v2
44+
45+
- name: Setup Node.js
46+
uses: actions/setup-node@v1
47+
with:
48+
node-version: ${{ env.NODE_VERSION_USED_FOR_DEVELOPMENT }}
49+
50+
# We install bunch of packages during integration tests without locking them
51+
# so we skip cache action to not pollute cache for other jobs.
52+
- name: Install Dependencies
53+
run: npm ci
54+
55+
- name: Build NPM package
56+
run: npm run build
57+
58+
- name: Run Integration Tests
59+
run: npm run check:integrations
60+
3861
coverage:
3962
name: Measure test coverage
4063
runs-on: ubuntu-latest

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
npm-debug.log
88

99
dist
10+
integrationTmp
1011
node_modules
1112
coverage

integrationTests/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# TBD

integrationTests/integration-test.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// @noflow
2+
3+
'use strict';
4+
5+
const fs = require('fs');
6+
const path = require('path');
7+
const childProcess = require('child_process');
8+
9+
const { describe, it } = require('mocha');
10+
11+
function exec(command, options = {}) {
12+
return childProcess.execSync(command, {
13+
stdio: 'inherit',
14+
...options,
15+
});
16+
}
17+
18+
describe('Integration Tests', () => {
19+
const tmpDir = path.resolve('./integrationTmp');
20+
fs.rmdirSync(tmpDir, { recursive: true });
21+
fs.mkdirSync(tmpDir);
22+
23+
it('Should compile with all supported TS versions', () => {
24+
exec(`cp -R ${path.join(__dirname, 'ts')} ${tmpDir}`);
25+
26+
const cwd = path.join(tmpDir, 'ts');
27+
exec('npm install --silent', { cwd });
28+
exec('npm test', { cwd });
29+
}).timeout(40000);
30+
});
File renamed without changes.

integrationTests/ts/package.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"scripts": {
3+
"test": "node test.js"
4+
},
5+
"dependencies": {
6+
"@types/node": "14.0.13",
7+
"express-graphql": "file:../../dist",
8+
"typescript-3.0": "npm:[email protected]",
9+
"typescript-3.1": "npm:[email protected]",
10+
"typescript-3.2": "npm:[email protected]",
11+
"typescript-3.3": "npm:[email protected]",
12+
"typescript-3.4": "npm:[email protected]",
13+
"typescript-3.5": "npm:[email protected]",
14+
"typescript-3.6": "npm:[email protected]",
15+
"typescript-3.7": "npm:[email protected]",
16+
"typescript-3.8": "npm:[email protected]",
17+
"typescript-3.9": "npm:[email protected]"
18+
}
19+
}

integrationTests/ts/test.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// @noflow
2+
3+
'use strict';
4+
5+
const path = require('path');
6+
const childProcess = require('child_process');
7+
8+
const { dependencies } = require('./package.json');
9+
10+
const tsVersions = Object.keys(dependencies)
11+
.filter((pkg) => pkg.startsWith('typescript-'))
12+
.sort((a, b) => b.localeCompare(a));
13+
14+
for (const version of tsVersions) {
15+
console.log(`Testing on ${version} ...`);
16+
17+
const tscPath = path.join(__dirname, 'node_modules', version, 'bin/tsc');
18+
childProcess.execSync(tscPath, { stdio: 'inherit' });
19+
}

integrationTests/ts/tsconfig.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"compilerOptions": {
3+
"module": "commonjs",
4+
"lib": ["es6", "esnext.asynciterable"],
5+
"strict": true,
6+
"noEmit": true
7+
}
8+
}

0 commit comments

Comments
 (0)