forked from Azure/azure-functions-nodejs-library
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTypes.test.ts
More file actions
33 lines (30 loc) · 1.18 KB
/
Copy pathTypes.test.ts
File metadata and controls
33 lines (30 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License.
import { expect } from 'chai';
import * as cp from 'child_process';
import { Context } from 'mocha';
import * as path from 'path';
describe('Public TypeScript types', () => {
for (const tsVersion of ['4']) {
it(`builds with TypeScript v${tsVersion}`, async function (this: Context) {
this.timeout(60 * 1000);
expect(await runTsBuild(tsVersion)).to.equal(2);
});
}
});
async function runTsBuild(tsVersion: string): Promise<number> {
const repoRoot = path.join(__dirname, '..');
const tscPath = path.join(repoRoot, 'node_modules', `typescript${tsVersion}`, 'bin', 'tsc');
const projectFile = path.join(repoRoot, 'test', 'types', 'tsconfig.json');
return new Promise<number>((resolve, reject) => {
const cmd = cp.spawn('node', [tscPath, '--project', projectFile]);
cmd.stdout.on('data', function (data) {
console.log(data.toString());
});
cmd.stderr.on('data', function (data) {
console.error(data.toString());
});
cmd.on('error', reject);
cmd.on('close', resolve);
});
}