Skip to content

Commit 98c2587

Browse files
committed
test: also copy other files from templates (except npm related)
1 parent 185a38d commit 98c2587

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

e2e/__helpers__/test-case.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ import { join } from 'path';
33
import * as Paths from '../../scripts/paths';
44
import * as fs from 'fs-extra';
55

6+
const TEMPLATE_EXCLUDED_ITEMS = [
7+
'node_modules',
8+
'package.json',
9+
'package-lock.json',
10+
];
11+
612
class TestCaseRunDescriptor {
713
// tslint:disable-next-line:variable-name
814
protected _options: RunTestOptions;
@@ -45,7 +51,9 @@ class TestCaseRunDescriptor {
4551
});
4652
if (logOutputUnlessStatusIs != null) {
4753
console.log(
48-
`Output of "${this.name}" using template "${this.templateName}":\n\n`,
54+
`Output of test run in "${this.name}" using template "${
55+
this.templateName
56+
}":\n\n`,
4957
result.output.trim(),
5058
);
5159
}
@@ -86,7 +94,7 @@ export function run(
8694

8795
const prefix =
8896
pkg.scripts && pkg.scripts.test
89-
? ['npm', 'run', 'test']
97+
? ['npm', '-s', 'run', 'test']
9098
: [join(dir, 'node_modules', '.bin', 'jest')];
9199
args = [...prefix, ...args];
92100
const cmd = args.shift();
@@ -133,5 +141,13 @@ function prepareTest(name: string, template: string): string {
133141
join(caseDir, 'node_modules'),
134142
);
135143

144+
// copy all other files from the template to the case dir
145+
fs.readdirSync(templateDir).forEach(item => {
146+
if (TEMPLATE_EXCLUDED_ITEMS.includes(item)) {
147+
return;
148+
}
149+
fs.copySync(join(templateDir, item), join(caseDir, item));
150+
});
151+
136152
return caseDir;
137153
}

scripts/e2e.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
'use strict';
33

44
process.env.NODE_ENV = 'test';
5+
process.env.PUBLIC_URL = '';
56
const jest = require('jest');
67
const { sync: spawnSync } = require('cross-spawn');
78
const fs = require('fs-extra');

0 commit comments

Comments
 (0)