Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 46b6dd1

Browse files
committedSep 2, 2022
ci: Move 'integration-test.ts' into 'resources'
Motivation: allow to reuse more stuff from 'resources/utils.ts' Working on rebasing graphql#3361 that adds even more code into integrationTests so want to keep it simple by reusing code from 'utils.ts'
1 parent a24a9f3 commit 46b6dd1

File tree

2 files changed

+4
-13
lines changed

2 files changed

+4
-13
lines changed
 

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"prettier": "prettier --cache --cache-strategy metadata --write --list-different .",
4545
"prettier:check": "prettier --cache --cache-strategy metadata --check .",
4646
"check:spelling": "cspell --cache --no-progress '**/*'",
47-
"check:integrations": "npm run build:npm && npm run build:deno && mocha --full-trace integrationTests/*-test.ts",
47+
"check:integrations": "npm run build:npm && npm run build:deno && mocha --full-trace resources/integration-test.ts",
4848
"serve": "docusaurus serve --dir websiteDist/ --config website/docusaurus.config.cjs",
4949
"start": "npm run build:website && npm run serve",
5050
"build:website": "ts-node resources/build-docusaurus.ts",

‎integrationTests/integration-test.ts ‎resources/integration-test.ts

+3-12
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,25 @@
1-
import childProcess from 'node:child_process';
21
import fs from 'node:fs';
32
import os from 'node:os';
43
import path from 'node:path';
54

65
import { describe, it } from 'mocha';
76

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';
178

189
describe('Integration Tests', () => {
1910
const tmpDir = path.join(os.tmpdir(), 'graphql-js-integrationTmp');
2011
fs.rmSync(tmpDir, { recursive: true, force: true });
2112
fs.mkdirSync(tmpDir);
2213

23-
const distDir = path.resolve('./npmDist');
14+
const distDir = localRepoPath('npmDist');
2415
const archiveName = npm(['--quiet', 'pack', distDir], { cwd: tmpDir });
2516
fs.renameSync(
2617
path.join(tmpDir, archiveName),
2718
path.join(tmpDir, 'graphql.tgz'),
2819
);
2920

3021
function testOnNodeProject(projectName: string) {
31-
const projectPath = new URL(projectName, import.meta.url).pathname;
22+
const projectPath = localRepoPath('integrationTests', projectName);
3223

3324
const packageJSONPath = path.join(projectPath, 'package.json');
3425
const packageJSON = JSON.parse(fs.readFileSync(packageJSONPath, 'utf-8'));

0 commit comments

Comments
 (0)
Please sign in to comment.