Skip to content

Commit 300da24

Browse files
authored
Merge pull request #243 from ysk8hori/update-integration-testing
Update integration testing
2 parents a6040d2 + ffc16e4 commit 300da24

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

integration.spec.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1-
import { beforeAll, expect, test } from 'vitest';
2-
import { $ } from 'zx';
31
import fs from 'fs';
42
import path from 'path';
3+
import { beforeAll, expect, test } from 'vitest';
4+
import { $ } from 'zx';
55

66
const dir = '__tmp__';
77
const filename = 'test.md';
88
const filepath = path.join(dir, filename);
99

10-
beforeAll(() => {
10+
beforeAll(async () => {
1111
if (!fs.existsSync(dir)) fs.mkdirSync(dir);
12+
await $`npm run build`;
1213
});
1314

1415
// TODO 現状、--config-file で指定するパスは -d からの相対パスだが、将来的には -d をなくしたい。その移行のため --config-file での指定は、-d を無視したカレントディレクトリからの相対パスで設定ファイルを優先し、なければ -d からの相対パスで探すようにしたい。
1516

1617
test('run:sample', async () => {
17-
await $`npx tsx ./src/cli/entry.ts --tsconfig './dummy_project/tsconfig.json' --md ${filepath}`;
18+
await $`node ./bin/tsg.js --tsconfig './dummy_project/tsconfig.json' --md ${filepath}`;
1819

1920
const file = fs.readFileSync(filepath, { encoding: 'utf-8' });
2021
expect(file).toMatchInlineSnapshot(`
@@ -118,7 +119,7 @@ test('run:sample', async () => {
118119
});
119120

120121
test('run:sample:argument-include', async () => {
121-
await $`npx tsx ./src/cli/entry.ts includeFiles config --tsconfig './dummy_project/tsconfig.json' --md ${filepath}`;
122+
await $`node ./bin/tsg.js includeFiles config --tsconfig './dummy_project/tsconfig.json' --md ${filepath}`;
122123

123124
const file = fs.readFileSync(filepath, { encoding: 'utf-8' });
124125
expect(file).toMatchInlineSnapshot(`
@@ -207,7 +208,7 @@ test('run:sample:argument-include', async () => {
207208
});
208209

209210
test('run:sample:include', async () => {
210-
await $`npx tsx ./src/cli/entry.ts --tsconfig './dummy_project/tsconfig.json' --include includeFiles config --md ${filepath}`;
211+
await $`node ./bin/tsg.js --tsconfig './dummy_project/tsconfig.json' --include includeFiles config --md ${filepath}`;
211212

212213
const file = fs.readFileSync(filepath, { encoding: 'utf-8' });
213214
expect(file).toMatchInlineSnapshot(`
@@ -296,7 +297,7 @@ test('run:sample:include', async () => {
296297
});
297298

298299
test('run:sample:exclude', async () => {
299-
await $`npx tsx ./src/cli/entry.ts --tsconfig './dummy_project/tsconfig.json' --include includeFiles config --exclude excludeFiles utils --md ${filepath}`;
300+
await $`node ./bin/tsg.js --tsconfig './dummy_project/tsconfig.json' --include includeFiles config --exclude excludeFiles utils --md ${filepath}`;
300301

301302
const file = fs.readFileSync(filepath, { encoding: 'utf-8' });
302303
expect(file).toMatchInlineSnapshot(`
@@ -357,7 +358,7 @@ test('run:sample:exclude', async () => {
357358
});
358359

359360
test('run:sample:abstraction', async () => {
360-
await $`npx tsx ./src/cli/entry.ts --tsconfig './dummy_project/tsconfig.json' --include includeFiles config --exclude excludeFiles utils --abstraction abstractions --md ${filepath}`;
361+
await $`node ./bin/tsg.js --tsconfig './dummy_project/tsconfig.json' --include includeFiles config --exclude excludeFiles utils --abstraction abstractions --md ${filepath}`;
361362

362363
const file = fs.readFileSync(filepath, { encoding: 'utf-8' });
363364
expect(file).toMatchInlineSnapshot(`
@@ -409,7 +410,7 @@ test('run:sample:abstraction', async () => {
409410
});
410411

411412
test('run:sample:highlight', async () => {
412-
await $`npx tsx ./src/cli/entry.ts --tsconfig './dummy_project/tsconfig.json' --include includeFiles config --exclude excludeFiles utils --abstraction abstractions --highlight config.ts b.ts --md ${filepath}`;
413+
await $`node ./bin/tsg.js --tsconfig './dummy_project/tsconfig.json' --include includeFiles config --exclude excludeFiles utils --abstraction abstractions --highlight config.ts b.ts --md ${filepath}`;
413414

414415
const file = fs.readFileSync(filepath, { encoding: 'utf-8' });
415416
expect(file).toMatchInlineSnapshot(`

integration.vue.spec.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1-
import { beforeAll, expect, test } from 'vitest';
2-
import { $ } from 'zx';
31
import fs from 'fs';
42
import path from 'path';
3+
import { beforeAll, expect, test } from 'vitest';
4+
import { $ } from 'zx';
55

66
const dir = '__tmp__';
77
const filename = 'test-vue.md';
88
const filepath = path.join(dir, filename);
99

10-
beforeAll(() => {
10+
beforeAll(async () => {
1111
if (!fs.existsSync(dir)) fs.mkdirSync(dir);
12+
await $`npm run build`;
1213
});
1314

1415
// TODO 現状、--config-file で指定するパスは -d からの相対パスだが、将来的には -d をなくしたい。その移行のため --config-file での指定は、-d を無視したカレントディレクトリからの相対パスで設定ファイルを優先し、なければ -d からの相対パスで探すようにしたい。
1516

1617
test('run:sample', async () => {
17-
await $`npx tsx ./src/cli/entry.ts --tsconfig './dummy_project/tsconfig.json' --md ${filepath} --vue`;
18+
await $`node ./bin/tsg.js --tsconfig './dummy_project/tsconfig.json' --md ${filepath} --vue`;
1819

1920
const file = fs.readFileSync(filepath, { encoding: 'utf-8' });
2021
expect(file).toMatchInlineSnapshot(`
@@ -124,7 +125,7 @@ test('run:sample', async () => {
124125
});
125126

126127
test('run:sample:argument-include', async () => {
127-
await $`npx tsx ./src/cli/entry.ts includeFiles config --tsconfig './dummy_project/tsconfig.json' --md ${filepath} --vue`;
128+
await $`node ./bin/tsg.js includeFiles config --tsconfig './dummy_project/tsconfig.json' --md ${filepath} --vue`;
128129

129130
const file = fs.readFileSync(filepath, { encoding: 'utf-8' });
130131
expect(file).toMatchInlineSnapshot(`
@@ -219,7 +220,7 @@ test('run:sample:argument-include', async () => {
219220
});
220221

221222
test('run:sample:include', async () => {
222-
await $`npx tsx ./src/cli/entry.ts --tsconfig './dummy_project/tsconfig.json' --include includeFiles config --md ${filepath} --vue`;
223+
await $`node ./bin/tsg.js --tsconfig './dummy_project/tsconfig.json' --include includeFiles config --md ${filepath} --vue`;
223224

224225
const file = fs.readFileSync(filepath, { encoding: 'utf-8' });
225226
expect(file).toMatchInlineSnapshot(`
@@ -314,7 +315,7 @@ test('run:sample:include', async () => {
314315
});
315316

316317
test('run:sample:exclude', async () => {
317-
await $`npx tsx ./src/cli/entry.ts --tsconfig './dummy_project/tsconfig.json' --include includeFiles config --exclude excludeFiles utils --md ${filepath} --vue`;
318+
await $`node ./bin/tsg.js --tsconfig './dummy_project/tsconfig.json' --include includeFiles config --exclude excludeFiles utils --md ${filepath} --vue`;
318319

319320
const file = fs.readFileSync(filepath, { encoding: 'utf-8' });
320321
expect(file).toMatchInlineSnapshot(`
@@ -381,7 +382,7 @@ test('run:sample:exclude', async () => {
381382
});
382383

383384
test('run:sample:abstraction', async () => {
384-
await $`npx tsx ./src/cli/entry.ts --tsconfig './dummy_project/tsconfig.json' --include includeFiles config --exclude excludeFiles utils --abstraction abstractions --md ${filepath} --vue`;
385+
await $`node ./bin/tsg.js --tsconfig './dummy_project/tsconfig.json' --include includeFiles config --exclude excludeFiles utils --abstraction abstractions --md ${filepath} --vue`;
385386

386387
const file = fs.readFileSync(filepath, { encoding: 'utf-8' });
387388
expect(file).toMatchInlineSnapshot(`
@@ -439,7 +440,7 @@ test('run:sample:abstraction', async () => {
439440
});
440441

441442
test('run:sample:highlight', async () => {
442-
await $`npx tsx ./src/cli/entry.ts --tsconfig './dummy_project/tsconfig.json' --include includeFiles config --exclude excludeFiles utils --abstraction abstractions --highlight config.ts b.ts --md ${filepath} --vue`;
443+
await $`node ./bin/tsg.js --tsconfig './dummy_project/tsconfig.json' --include includeFiles config --exclude excludeFiles utils --abstraction abstractions --highlight config.ts b.ts --md ${filepath} --vue`;
443444

444445
const file = fs.readFileSync(filepath, { encoding: 'utf-8' });
445446
expect(file).toMatchInlineSnapshot(`

0 commit comments

Comments
 (0)