-
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathdefault.test.mjs
More file actions
145 lines (125 loc) · 3.92 KB
/
default.test.mjs
File metadata and controls
145 lines (125 loc) · 3.92 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
import { describe, it, expect } from 'vitest';
import { join } from 'path';
import { existsSync, writeFileSync } from 'fs';
import stripAnsi from 'strip-ansi';
import { newProjectWithFixtures } from './helpers.mjs';
const SCENARIOS = [
{
flags: [
/* none, default */
],
fixturePath: join(import.meta.dirname, 'fixture'),
},
{
flags: ['--typescript'],
fixturePath: join(import.meta.dirname, 'fixture-ts'),
},
];
describe('basic functionality', function () {
for (let { flags, fixturePath } of SCENARIOS) {
describe(`with flags: '${flags.join(' ')}'`, function () {
let project = newProjectWithFixtures({
fixturePath,
flags,
});
it('verify files', async function () {
expect(
!existsSync(join(project.dir(), 'app/index.html')),
'the app index.html has been removed',
);
expect(
existsSync(join(project.dir(), 'index.html')),
'the root index.html has been added',
);
});
it('successfully lints', async function () {
let result = await project.execa('pnpm', ['lint']);
console.log(result.stdout);
});
it('successfully builds', async function () {
let result = await project.execa('pnpm', ['build']);
console.log(result.stdout);
});
it('successfully runs tests', async function () {
let result;
try {
result = await project.execa('pnpm', ['test:ember']);
} catch (err) {
console.log(err.stdout, err.stderr);
throw 'Failed to successfully run test:ember';
}
// make sure that each of the tests that we expect actually show up
// alternatively we can change this to search for `pass 3`
expect(result.stdout).to.contain(
'Acceptance | welcome page: visiting /index shows the welcome page',
);
expect(result.stdout).to.contain(
'Acceptance | styles: visiting /styles',
);
console.log(result.stdout);
});
it('successfully runs tests in dev mode', async function () {
await project.$`pnpm install --save-dev testem http-proxy`;
let appURL;
let server;
try {
server = project.execa('pnpm', ['start']);
await new Promise((resolve) => {
server.stdout.on('data', (line) => {
let result = /Local:\s+(https?:\/\/.*)\//g.exec(
stripAnsi(line.toString()),
);
if (result) {
appURL = result[1];
resolve();
}
});
});
writeFileSync(
join(project.dir(), 'testem-dev.cjs'),
`module.exports = {
test_page: 'tests/index.html?hidepassed',
disable_watching: true,
launch_in_ci: ['Chrome'],
launch_in_dev: ['Chrome'],
browser_start_timeout: 120,
browser_args: {
Chrome: {
ci: [
// --no-sandbox is needed when running Chrome inside a container
process.env.CI ? '--no-sandbox' : null,
'--headless',
'--disable-dev-shm-usage',
'--disable-software-rasterizer',
'--mute-audio',
'--remote-debugging-port=0',
'--window-size=1440,900',
].filter(Boolean),
},
},
middleware: [
require(__dirname + '/testem-proxy.cjs')('${appURL}')
],
};
`,
);
let testResult = await project.execa('pnpm', [
'testem',
'--file',
'testem-dev.cjs',
'ci',
]);
expect(testResult.exitCode).to.eq(0, testResult.output);
} finally {
server?.kill('SIGINT');
}
});
it('successfully optimizes deps', function () {
return project.execa('pnpm', ['vite', 'optimize', '--force']);
});
it('can run generators', function () {
return project.execa('pnpm', ['ember', 'g', 'route', 'fancy']);
});
});
}
});