This repository has been archived by the owner on Mar 8, 2023. It is now read-only.
/
test.js
59 lines (48 loc) · 1.58 KB
/
test.js
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
const fs = require("fs");
const fsExtra = require("fs.extra");
const path = require("path");
const yeomanTestHelpers = require("yeoman-test");
const {
assert
} = require("chai");
const {
spawnSync
} = require('child_process');
/*
Note, in certain environments, custom .npmrc may be needed to run these tests, use like this:
USE_NPMRC=~/.npmrc npx mocha
*/
describe("YeomMan Generator harp.gl:app", function () {
this.timeout(300000);
let helperDirectory;
before(async function () {
helperDirectory = await yeomanTestHelpers.run(path.join(__dirname, '../generators/app'))
.inTmpDir(function (dir) {
if (process.env.USE_NPMRC) {
const targetPath = path.join(dir, ".npmrc");
fs.copyFileSync(process.env.USE_NPMRC, targetPath);
}
})
.withPrompts({
'access_token': 'test_token'
});
assert.isString(helperDirectory);
});
it("webpack", async function () {
const installStatus = spawnSync("npm", ["install"], {
cwd: helperDirectory
});
assert.strictEqual(installStatus.status, 0, installStatus.output);
const buildStatus = spawnSync("npm", ["run", "build"], {
cwd: helperDirectory
});
assert.strictEqual(buildStatus.status, 0, buildStatus.output);
});
after(function () {
if (process.env.KEEP_TEMP_DIR) {
console.log("Keeping", helperDirectory);
} else {
fsExtra.rmrfSync(helperDirectory);
}
});
});