|
1 |
| -import childProcess from 'node:child_process'; |
2 | 1 | import fs from 'node:fs';
|
3 | 2 | import os from 'node:os';
|
4 | 3 | import path from 'node:path';
|
5 | 4 |
|
6 | 5 | import { describe, it } from 'mocha';
|
7 | 6 |
|
8 |
| -function npm(args: ReadonlyArray<string>, options = {}): string { |
9 |
| - const result = childProcess.spawnSync('npm', [...args], { |
10 |
| - maxBuffer: 10 * 1024 * 1024, // 10MB |
11 |
| - stdio: ['inherit', 'pipe', 'inherit'], |
12 |
| - encoding: 'utf-8', |
13 |
| - ...options, |
14 |
| - }); |
15 |
| - return result.stdout.toString().trimEnd(); |
16 |
| -} |
| 7 | +import { localRepoPath, npm } from './utils.js'; |
17 | 8 |
|
18 | 9 | describe('Integration Tests', () => {
|
19 | 10 | const tmpDir = path.join(os.tmpdir(), 'graphql-js-integrationTmp');
|
20 | 11 | fs.rmSync(tmpDir, { recursive: true, force: true });
|
21 | 12 | fs.mkdirSync(tmpDir);
|
22 | 13 |
|
23 |
| - const distDir = path.resolve('./npmDist'); |
| 14 | + const distDir = localRepoPath('npmDist'); |
24 | 15 | const archiveName = npm(['--quiet', 'pack', distDir], { cwd: tmpDir });
|
25 | 16 | fs.renameSync(
|
26 | 17 | path.join(tmpDir, archiveName),
|
27 | 18 | path.join(tmpDir, 'graphql.tgz'),
|
28 | 19 | );
|
29 | 20 |
|
30 | 21 | function testOnNodeProject(projectName: string) {
|
31 |
| - const projectPath = new URL(projectName, import.meta.url).pathname; |
| 22 | + const projectPath = localRepoPath('integrationTests', projectName); |
32 | 23 |
|
33 | 24 | const packageJSONPath = path.join(projectPath, 'package.json');
|
34 | 25 | const packageJSON = JSON.parse(fs.readFileSync(packageJSONPath, 'utf-8'));
|
|
0 commit comments