@ember/app-blueprint 0.8.2 → 6.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/.prettierignore +1 -2
  2. package/.release-plan.json +9 -5
  3. package/CHANGELOG.md +17 -0
  4. package/eslint.config.mjs +1 -5
  5. package/files/package.json +43 -43
  6. package/package.json +2 -2
  7. package/tests/arguments.test.mjs +155 -0
  8. package/tests/fixtures/tests-js-10/app/components/.gitkeep +0 -0
  9. package/tests/fixtures/tests-js-10/app/components/sweet.gjs +3 -0
  10. package/tests/{fixture → fixtures/tests-js-10}/app/router.js +2 -3
  11. package/tests/fixtures/tests-js-10/app/routes/.gitkeep +0 -0
  12. package/tests/{fixture/app/routes/styles.js → fixtures/tests-js-10/app/routes/fancy.js} +1 -1
  13. package/tests/fixtures/tests-js-10/app/styles/app.css +3 -0
  14. package/tests/fixtures/tests-js-10/app/templates/application.gjs +15 -0
  15. package/tests/fixtures/tests-js-10/app/templates/fancy.gjs +12 -0
  16. package/tests/fixtures/tests-js-10/tests/acceptance/index-test.js +26 -0
  17. package/tests/fixtures/tests-js-10/tests/integration/components/sweet-test.gjs +28 -0
  18. package/tests/fixtures/tests-js-10/tests/routes/fancy-test.js +11 -0
  19. package/tests/{fixture-ts/testem-proxy.js → fixtures/tests-js-20/testem-dev.js} +26 -2
  20. package/tests/fixtures/tests-ts-10/app/components/.gitkeep +0 -0
  21. package/tests/fixtures/tests-ts-10/app/components/sweet.gts +3 -0
  22. package/tests/{fixture-ts → fixtures/tests-ts-10}/app/router.ts +2 -3
  23. package/tests/fixtures/tests-ts-10/app/routes/.gitkeep +0 -0
  24. package/tests/{fixture-ts/app/routes/styles.ts → fixtures/tests-ts-10/app/routes/fancy.ts} +1 -1
  25. package/tests/fixtures/tests-ts-10/app/styles/app.css +3 -0
  26. package/tests/fixtures/tests-ts-10/app/templates/application.gts +15 -0
  27. package/tests/fixtures/tests-ts-10/app/templates/fancy.gts +12 -0
  28. package/tests/fixtures/tests-ts-10/tests/acceptance/index-test.ts +26 -0
  29. package/tests/fixtures/tests-ts-10/tests/integration/components/sweet-test.gjs +28 -0
  30. package/tests/fixtures/tests-ts-10/tests/routes/fancy-test.js +11 -0
  31. package/tests/generators.test.mjs +60 -0
  32. package/tests/helpers.mjs +26 -91
  33. package/tests/lint.test.mjs +27 -10
  34. package/tests/tests.test.mjs +218 -0
  35. package/vitest.config.ts +2 -2
  36. package/tests/default.test.mjs +0 -155
  37. package/tests/fixture/app/components/custom-component.hbs +0 -3
  38. package/tests/fixture/app/styles/app.css +0 -5
  39. package/tests/fixture/app/templates/application.hbs +0 -3
  40. package/tests/fixture/app/templates/custom-component.hbs +0 -1
  41. package/tests/fixture/app/templates/index.hbs +0 -1
  42. package/tests/fixture/app/templates/styles.hbs +0 -5
  43. package/tests/fixture/testem-proxy.js +0 -35
  44. package/tests/fixture/tests/acceptance/custom-component-test.js +0 -14
  45. package/tests/fixture/tests/acceptance/styles-test.js +0 -18
  46. package/tests/fixture-ts/app/styles/app.css +0 -5
  47. package/tests/fixture-ts/app/templates/components/custom.gts +0 -5
  48. package/tests/fixture-ts/app/templates/custom-component.gts +0 -5
  49. package/tests/fixture-ts/app/templates/index.gts +0 -5
  50. package/tests/fixture-ts/app/templates/styles.gts +0 -7
  51. package/tests/fixture-ts/tests/acceptance/custom-component-test.ts +0 -14
  52. package/tests/fixture-ts/tests/acceptance/styles-test.ts +0 -18
  53. package/tests/typescript.test.mjs +0 -24
  54. /package/tests/{fixture → fixtures/tests-js-10}/app/initializers/test-init.js +0 -0
  55. /package/tests/{fixture → fixtures/tests-js-10}/app/instance-initializers/test-instance-init.js +0 -0
  56. /package/tests/{fixture → fixtures/tests-js-10}/tests/acceptance/app-init-test.js +0 -0
  57. /package/tests/{fixture → fixtures/tests-js-10}/tests/acceptance/welcome-page-test.js +0 -0
  58. /package/tests/{fixture-ts → fixtures/tests-ts-10}/app/initializers/test-init.ts +0 -0
  59. /package/tests/{fixture-ts → fixtures/tests-ts-10}/app/instance-initializers/test-instance-init.ts +0 -0
  60. /package/tests/{fixture-ts → fixtures/tests-ts-10}/tests/acceptance/app-init-test.ts +0 -0
  61. /package/tests/{fixture-ts → fixtures/tests-ts-10}/tests/acceptance/welcome-page-test.ts +0 -0
@@ -0,0 +1,28 @@
1
+ import { module, test } from 'qunit';
2
+ import { setupRenderingTest } from 'test-app/tests/helpers';
3
+ import { render } from '@ember/test-helpers';
4
+ import Sweet from 'test-app/components/sweet';
5
+
6
+ module('Integration | Component | sweet', function (hooks) {
7
+ setupRenderingTest(hooks);
8
+
9
+ test('it renders', async function (assert) {
10
+ // Updating values is achieved using autotracking, just like in app code. For example:
11
+ // class State { @tracked myProperty = 0; }; const state = new State();
12
+ // and update using state.myProperty = 1; await rerender();
13
+ // Handle any actions with function myAction(val) { ... };
14
+
15
+ await render(<template><Sweet /></template>);
16
+
17
+ assert.dom().hasText('');
18
+
19
+ // Template block usage:
20
+ await render(<template>
21
+ <Sweet>
22
+ template block text
23
+ </Sweet>
24
+ </template>);
25
+
26
+ assert.dom().hasText('template block text');
27
+ });
28
+ });
@@ -0,0 +1,11 @@
1
+ import { module, test } from 'qunit';
2
+ import { setupTest } from 'test-app/tests/helpers';
3
+
4
+ module('Unit | Route | fancy', function (hooks) {
5
+ setupTest(hooks);
6
+
7
+ test('it exists', function (assert) {
8
+ let route = this.owner.lookup('route:fancy');
9
+ assert.ok(route);
10
+ });
11
+ });
@@ -0,0 +1,60 @@
1
+ import { beforeAll, describe, it, expect } from 'vitest';
2
+
3
+ import { generateApp } from './helpers.mjs';
4
+
5
+ describe('Slow(JavaScript): Generate individual files', function () {
6
+ let app;
7
+
8
+ beforeAll(async function () {
9
+ app = await generateApp({ flags: ['--pnpm'], skipNpm: false });
10
+ });
11
+
12
+ it('can generate a route', async function () {
13
+ let { exitCode, stdout } = await app.execa('pnpm', [
14
+ 'ember',
15
+ 'g',
16
+ 'route',
17
+ 'fancy',
18
+ ]);
19
+
20
+ if (!process.env.CI) {
21
+ console.log(stdout);
22
+ }
23
+
24
+ expect(exitCode).to.equal(0);
25
+ expect(app.files.app.routes['fancy.js']).to.not.be.undefined;
26
+ expect(app.files.app['router.js']).to.contain(`this.route('fancy')`);
27
+ expect(app.files.tests.unit.routes['fancy-test.js']).to.not.be.undefined;
28
+ });
29
+
30
+ // Note: We could run additional generators here (component, controller, etc)
31
+ });
32
+
33
+ describe('Slow(TypeScript): Generate individual files', function () {
34
+ let app;
35
+
36
+ beforeAll(async function () {
37
+ app = await generateApp({
38
+ flags: ['--pnpm', '--typescript'],
39
+ skipNpm: false,
40
+ });
41
+ });
42
+
43
+ it('can generate a route', async function () {
44
+ let { exitCode, stdout } = await app.execa('pnpm', [
45
+ 'ember',
46
+ 'g',
47
+ 'route',
48
+ 'fancy',
49
+ ]);
50
+
51
+ if (!process.env.CI) {
52
+ console.log(stdout);
53
+ }
54
+
55
+ expect(exitCode).to.equal(0);
56
+ expect(app.files.app.routes['fancy.ts']).to.not.be.undefined;
57
+ expect(app.files.app['router.ts']).to.contain(`this.route('fancy')`);
58
+ expect(app.files.tests.unit.routes['fancy-test.ts']).to.not.be.undefined;
59
+ });
60
+ });
package/tests/helpers.mjs CHANGED
@@ -1,80 +1,45 @@
1
- import assert from 'node:assert';
2
-
3
- import { beforeAll } from 'vitest';
4
- import { sync as resolveBinSync } from 'resolve-bin';
5
1
  import { execa } from 'execa';
6
2
  import tmp from 'tmp-promise';
7
- import fs from 'node:fs/promises';
8
3
  import { join } from 'node:path';
9
4
  import fixturify from 'fixturify';
10
5
 
11
6
  let localEmberCli = require.resolve('ember-cli/bin/ember');
12
7
  const blueprintPath = join(__dirname, '..');
13
8
 
14
- function findEmber() {
15
- return resolveBinSync('ember-cli', { executable: 'ember' });
16
- }
17
-
18
- export const emberCli = findEmber();
19
-
20
- const appName = 'test-app';
21
-
22
- export function newProject({ name = appName, flags = [] } = {}) {
23
- let dir;
24
-
25
- beforeAll(async () => {
26
- const tmpDir = (await tmp.dir()).path;
27
- dir = join(tmpDir, name);
28
- await execa({
29
- cwd: tmpDir,
30
- })`${localEmberCli} new ${name} -b ${blueprintPath} --skip-git --pnpm ${flags}`;
31
- });
32
-
33
- return {
34
- appName: () => name,
35
- dir: () => dir,
36
- $: (...args) => execa({ cwd: dir })(...args),
37
- execa: (program, args, options = {}) => {
38
- return execa(program, args, {
39
- cwd: dir,
40
- ...options,
41
- });
42
- },
43
- };
44
- }
45
-
46
- export function newProjectWithFixtures({
9
+ export async function generateApp({
10
+ name = 'test-app',
47
11
  flags = [],
48
- fixturePath,
49
- packageJson = {},
50
- name = appName,
12
+ skipNpm = true,
51
13
  } = {}) {
52
- let dir;
14
+ const tmpDir = (await tmp.dir()).path;
15
+ const dir = join(tmpDir, name);
53
16
 
54
- assert(fixturePath, `a fixturePath is required`);
55
-
56
- beforeAll(async () => {
57
- const tmpDir = (await tmp.dir()).path;
58
- dir = join(tmpDir, name);
59
- await execa({
60
- cwd: tmpDir,
61
- })`${localEmberCli} new ${name} -b ${blueprintPath} --skip-git --pnpm ${flags}`;
17
+ if (skipNpm) {
18
+ flags.push('--skip-npm');
19
+ }
62
20
 
63
- let addonFixture = fixturify.readSync(fixturePath);
64
- fixturify.writeSync(dir, addonFixture);
21
+ const execaOptions = {
22
+ cwd: tmpDir,
23
+ };
65
24
 
66
- await mergePackageJson(dir, packageJson);
25
+ if (!process.env.CI) {
26
+ execaOptions.stdio = 'inherit';
27
+ }
67
28
 
68
- // Sync the lints for the fixtures with the project's config
69
- await execa(`pnpm`, ['lint:fix'], {
70
- cwd: dir,
71
- });
72
- });
29
+ const { stdout, stderr } = await execa(
30
+ localEmberCli,
31
+ ['new', name, '--blueprint', blueprintPath, '--skip-git', ...flags],
32
+ execaOptions,
33
+ );
73
34
 
74
35
  return {
75
- appName: () => name,
76
- dir: () => dir,
77
- $: (...args) => execa({ cwd: dir })(...args),
36
+ stdout,
37
+ stderr,
38
+ name,
39
+ dir,
40
+ get files() {
41
+ return fixturify.readSync(dir);
42
+ },
78
43
  execa: (program, args, options = {}) => {
79
44
  return execa(program, args, {
80
45
  cwd: dir,
@@ -83,33 +48,3 @@ export function newProjectWithFixtures({
83
48
  },
84
49
  };
85
50
  }
86
-
87
- async function mergePackageJson(dir, packageJson) {
88
- let rootKeys = Object.keys(packageJson || {});
89
-
90
- if (rootKeys.length === 0) {
91
- return;
92
- }
93
-
94
- let packageJsonPath = join(dir, 'package.json');
95
- let testPackageJson = JSON.parse(
96
- (await fs.readFile(packageJsonPath)).toString(),
97
- );
98
-
99
- for (let rootKey of rootKeys) {
100
- /**
101
- * For searchability in logs
102
- */
103
- console.log(`Modifying ${rootKey} in package.json @ ${packageJsonPath}`);
104
- let value = packageJson[rootKey];
105
-
106
- let isObject = typeof value === 'object' && !Array.isArray(value);
107
- if (!isObject) {
108
- throw new Error(`${rootKey} customization is currently not implemented`);
109
- }
110
-
111
- Object.assign(testPackageJson[rootKey], value);
112
- }
113
-
114
- await fs.writeFile(packageJsonPath, JSON.stringify(testPackageJson, null, 2));
115
- }
@@ -1,26 +1,43 @@
1
- import { describe, it, expect } from 'vitest';
1
+ import { beforeAll, describe, it, expect } from 'vitest';
2
2
 
3
- import { newProject } from './helpers.mjs';
3
+ import { generateApp } from './helpers.mjs';
4
4
 
5
5
  describe('linting & formatting', function () {
6
- describe('JavaScript', function () {
7
- let project = newProject();
6
+ let app;
8
7
 
9
- it('yields output for JavaScript without errors', async function () {
10
- let { exitCode } = await project.execa('pnpm', ['lint']);
8
+ beforeAll(async function () {
9
+ app = await generateApp({ flags: ['--typescript'], skipNpm: false });
10
+ });
11
+
12
+ describe('JavaScript', function () {
13
+ it('yields output without errors', async function () {
14
+ let { exitCode } = await app.execa('pnpm', ['lint']);
11
15
 
12
16
  expect(exitCode).to.equal(0);
13
17
  });
14
18
  });
15
19
 
16
20
  describe('TypeScript', function () {
17
- let project = newProject({
18
- flags: ['--typescript'],
21
+ let app;
22
+
23
+ beforeAll(async function () {
24
+ app = await generateApp({ flags: ['--typescript'], skipNpm: false });
19
25
  });
20
26
 
21
- it('yields output for JavaScript without errors', async function () {
22
- let { exitCode } = await project.execa('pnpm', ['lint']);
27
+ it('yields output without errors', async function () {
28
+ let { exitCode } = await app.execa('pnpm', ['lint']);
29
+
30
+ expect(exitCode).to.equal(0);
31
+ });
32
+
33
+ it('glint passes', async function () {
34
+ expect(
35
+ JSON.parse(app.files['package.json']).scripts['lint:types'],
36
+ ).to.equal('glint');
37
+
38
+ let { exitCode, stdout } = await app.execa('pnpm', ['lint:types']);
23
39
 
40
+ console.log(stdout);
24
41
  expect(exitCode).to.equal(0);
25
42
  });
26
43
  });
@@ -0,0 +1,218 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import fixturify from 'fixturify';
3
+ import stripAnsi from 'strip-ansi';
4
+
5
+ import { generateApp } from './helpers.mjs';
6
+
7
+ describe('Slow(JavaScript): Runs tests', async function () {
8
+ it('runs in a freshly generated app', async function () {
9
+ let app = await generateApp({ flags: ['--pnpm'], skipNpm: false });
10
+
11
+ let { stdout: stdout1, exitCode: exitCode1 } = await app.execa('pnpm', [
12
+ 'test',
13
+ ]);
14
+
15
+ if (!process.env.CI) {
16
+ console.log(stdout1);
17
+ }
18
+
19
+ expect(stdout1).to.contain('# tests 1');
20
+ expect(stdout1).to.contain('# pass 1');
21
+ expect(stdout1).to.contain('# skip 0');
22
+ expect(stdout1).to.contain('# todo 0');
23
+ expect(stdout1).to.contain('# ok');
24
+ expect(exitCode1).to.equal(0);
25
+ });
26
+
27
+ it('runs in an app with fixtures', async function () {
28
+ let app = await generateApp({ flags: ['--pnpm'], skipNpm: false });
29
+
30
+ fixturify.writeSync(
31
+ app.dir,
32
+ fixturify.readSync('./tests/fixtures/tests-js-10'),
33
+ );
34
+
35
+ let { stdout: stdout2, exitCode: exitCode2 } = await app.execa('pnpm', [
36
+ 'test',
37
+ ]);
38
+
39
+ if (!process.env.CI) {
40
+ console.log(stdout2);
41
+ }
42
+
43
+ expect(stdout2).to.match(/ok .* Acceptance \| app route/);
44
+ expect(stdout2).to.match(/ok .* Acceptance \| index/);
45
+ expect(stdout2).to.match(/ok .* Integration \| Component \| sweet/);
46
+ expect(stdout2).to.match(/ok .* Unit \| Route \| fancy/);
47
+ expect(stdout2).to.match(/ok .* Ember.onerror/);
48
+
49
+ expect(stdout2).to.contain('# tests 6');
50
+ expect(stdout2).to.contain('# pass 6');
51
+ expect(stdout2).to.contain('# skip 0');
52
+ expect(stdout2).to.contain('# todo 0');
53
+ expect(stdout2).to.contain('# ok');
54
+ expect(exitCode2).to.equal(0);
55
+ });
56
+
57
+ it('runs when serving /tests', async function () {
58
+ let app = await generateApp({ flags: ['--pnpm'], skipNpm: false });
59
+
60
+ await app.execa('pnpm', ['install', '--save-dev', 'testem', 'http-proxy']);
61
+
62
+ let fixtures = fixturify.readSync('./tests/fixtures/tests-js-20');
63
+ let server;
64
+
65
+ try {
66
+ server = app.execa('pnpm', ['start']);
67
+
68
+ let appURL = await new Promise((resolve) => {
69
+ // Read app url from Vite server output
70
+ server.stdout.on('data', (line) => {
71
+ let parsed = stripAnsi(line.toString());
72
+ let result = /Local:\s+(https?:\/\/.*)\//g.exec(parsed);
73
+
74
+ if (process.env.CI) {
75
+ console.log(parsed);
76
+ }
77
+
78
+ if (result) {
79
+ resolve(result[1]);
80
+ }
81
+ });
82
+ });
83
+
84
+ fixtures['testem-dev.js'] = fixtures['testem-dev.js'].replace(
85
+ '%APP_URL%',
86
+ appURL,
87
+ );
88
+ fixturify.writeSync(app.dir, fixtures);
89
+
90
+ let testResult = await app.execa('pnpm', [
91
+ 'testem',
92
+ '--file',
93
+ 'testem-dev.js',
94
+ 'ci',
95
+ ]);
96
+
97
+ if (process.env.CI) {
98
+ console.log(testResult.stdout);
99
+ console.log(testResult.stderr);
100
+ }
101
+
102
+ expect(testResult.exitCode).to.eq(0);
103
+ } finally {
104
+ server?.kill('SIGKILL');
105
+ }
106
+ });
107
+ });
108
+
109
+ describe('Slow(TypeScript): Runs tests', async function () {
110
+ it('runs in a freshly generated app', async function () {
111
+ let app = await generateApp({
112
+ flags: ['--pnpm', '--typescript'],
113
+ skipNpm: false,
114
+ });
115
+
116
+ let { stdout: stdout1, exitCode: exitCode1 } = await app.execa('pnpm', [
117
+ 'test',
118
+ ]);
119
+
120
+ if (!process.env.CI) {
121
+ console.log(stdout1);
122
+ }
123
+
124
+ expect(stdout1).to.contain('# tests 1');
125
+ expect(stdout1).to.contain('# pass 1');
126
+ expect(stdout1).to.contain('# skip 0');
127
+ expect(stdout1).to.contain('# todo 0');
128
+ expect(stdout1).to.contain('# ok');
129
+ expect(exitCode1).to.equal(0);
130
+ });
131
+
132
+ it('runs in an app with fixtures', async function () {
133
+ let app = await generateApp({
134
+ flags: ['--pnpm', '--typescript'],
135
+ skipNpm: false,
136
+ });
137
+
138
+ fixturify.writeSync(
139
+ app.dir,
140
+ fixturify.readSync('./tests/fixtures/tests-ts-10'),
141
+ );
142
+
143
+ let { stdout: stdout2, exitCode: exitCode2 } = await app.execa('pnpm', [
144
+ 'test',
145
+ ]);
146
+
147
+ if (!process.env.CI) {
148
+ console.log(stdout2);
149
+ }
150
+
151
+ expect(stdout2).to.match(/ok .* Acceptance \| app route/);
152
+ expect(stdout2).to.match(/ok .* Acceptance \| index/);
153
+ expect(stdout2).to.match(/ok .* Integration \| Component \| sweet/);
154
+ expect(stdout2).to.match(/ok .* Unit \| Route \| fancy/);
155
+ expect(stdout2).to.match(/ok .* Ember.onerror/);
156
+
157
+ expect(stdout2).to.contain('# tests 6');
158
+ expect(stdout2).to.contain('# pass 6');
159
+ expect(stdout2).to.contain('# skip 0');
160
+ expect(stdout2).to.contain('# todo 0');
161
+ expect(stdout2).to.contain('# ok');
162
+ expect(exitCode2).to.equal(0);
163
+ });
164
+
165
+ it('runs when serving /tests', async function () {
166
+ let app = await generateApp({
167
+ flags: ['--pnpm', '--typescript'],
168
+ skipNpm: false,
169
+ });
170
+
171
+ await app.execa('pnpm', ['install', '--save-dev', 'testem', 'http-proxy']);
172
+
173
+ let fixtures = fixturify.readSync('./tests/fixtures/tests-js-20');
174
+ let server;
175
+
176
+ try {
177
+ server = app.execa('pnpm', ['start']);
178
+
179
+ let appURL = await new Promise((resolve) => {
180
+ // Read app url from Vite server output
181
+ server.stdout.on('data', (line) => {
182
+ let parsed = stripAnsi(line.toString());
183
+ let result = /Local:\s+(https?:\/\/.*)\//g.exec(parsed);
184
+
185
+ if (process.env.CI) {
186
+ console.log(parsed);
187
+ }
188
+
189
+ if (result) {
190
+ resolve(result[1]);
191
+ }
192
+ });
193
+ });
194
+
195
+ fixtures['testem-dev.js'] = fixtures['testem-dev.js'].replace(
196
+ '%APP_URL%',
197
+ appURL,
198
+ );
199
+ fixturify.writeSync(app.dir, fixtures);
200
+
201
+ let testResult = await app.execa('pnpm', [
202
+ 'testem',
203
+ '--file',
204
+ 'testem-dev.js',
205
+ 'ci',
206
+ ]);
207
+
208
+ if (process.env.CI) {
209
+ console.log(testResult.stdout);
210
+ console.log(testResult.stderr);
211
+ }
212
+
213
+ expect(testResult.exitCode).to.eq(0);
214
+ } finally {
215
+ server?.kill('SIGKILL');
216
+ }
217
+ });
218
+ });
package/vitest.config.ts CHANGED
@@ -4,7 +4,7 @@ const ONE_SECOND = 1_000;
4
4
 
5
5
  export default defineConfig({
6
6
  test: {
7
- testTimeout: 100 * ONE_SECOND,
8
- hookTimeout: 150 * ONE_SECOND,
7
+ testTimeout: 240 * ONE_SECOND,
8
+ hookTimeout: 240 * ONE_SECOND,
9
9
  },
10
10
  });
@@ -1,155 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { join } from 'path';
3
- import { existsSync, writeFileSync } from 'fs';
4
- import stripAnsi from 'strip-ansi';
5
- import { newProjectWithFixtures } from './helpers.mjs';
6
-
7
- const SCENARIOS = [
8
- {
9
- name: 'defaults',
10
- flags: [],
11
- fixturePath: join(import.meta.dirname, 'fixture'),
12
- },
13
- {
14
- name: 'compat (v1 addon support)',
15
- // @glimmer/component >= 2.0.0 is a v2 addon, which we don't need when testing "compat mode"
16
- // this test is "compat mode"
17
- // compat mode forces us to use v1 addon infra, ember-cli, etc
18
- flags: [
19
- /* none, default */
20
- ],
21
- packageJson: {
22
- devDependencies: {
23
- '@glimmer/component': '^1.1.2',
24
- },
25
- },
26
- fixturePath: join(import.meta.dirname, 'fixture'),
27
- },
28
- {
29
- name: 'typescript',
30
- flags: ['--typescript'],
31
- fixturePath: join(import.meta.dirname, 'fixture-ts'),
32
- },
33
- ];
34
-
35
- describe('basic functionality', function () {
36
- for (let { name, flags, packageJson, fixturePath } of SCENARIOS) {
37
- describe(name, function () {
38
- let project = newProjectWithFixtures({
39
- fixturePath,
40
- flags,
41
- packageJson,
42
- });
43
-
44
- it('verify files', async function () {
45
- expect(
46
- !existsSync(join(project.dir(), 'app/index.html')),
47
- 'the app index.html has been removed',
48
- );
49
- expect(
50
- existsSync(join(project.dir(), 'index.html')),
51
- 'the root index.html has been added',
52
- );
53
- });
54
-
55
- it('successfully builds', async function () {
56
- let result = await project.execa('pnpm', ['build']);
57
-
58
- console.log(result.stdout);
59
- });
60
-
61
- it('successfully runs tests', async function () {
62
- let result;
63
-
64
- try {
65
- result = await project.execa('pnpm', ['test']);
66
- } catch (err) {
67
- console.log(err.stdout, err.stderr);
68
- throw 'Failed to successfully run test';
69
- }
70
-
71
- // make sure that each of the tests that we expect actually show up
72
- // alternatively we can change this to search for `pass 3`
73
- expect(result.stdout).to.contain(
74
- 'Acceptance | welcome page: visiting /index shows the welcome page',
75
- );
76
- expect(result.stdout).to.contain(
77
- 'Acceptance | styles: visiting /styles',
78
- );
79
-
80
- console.log(result.stdout);
81
- });
82
-
83
- it('successfully runs tests in dev mode', async function () {
84
- await project.$`pnpm install --save-dev testem http-proxy`;
85
- let appURL;
86
-
87
- let server;
88
-
89
- try {
90
- server = project.execa('pnpm', ['start']);
91
-
92
- await new Promise((resolve) => {
93
- server.stdout.on('data', (line) => {
94
- let result = /Local:\s+(https?:\/\/.*)\//g.exec(
95
- stripAnsi(line.toString()),
96
- );
97
-
98
- if (result) {
99
- appURL = result[1];
100
- resolve();
101
- }
102
- });
103
- });
104
-
105
- writeFileSync(
106
- join(project.dir(), 'testem-dev.js'),
107
- `module.exports = {
108
- test_page: 'tests/index.html?hidepassed',
109
- disable_watching: true,
110
- launch_in_ci: ['Chrome'],
111
- launch_in_dev: ['Chrome'],
112
- browser_start_timeout: 120,
113
- browser_args: {
114
- Chrome: {
115
- ci: [
116
- // --no-sandbox is needed when running Chrome inside a container
117
- process.env.CI ? '--no-sandbox' : null,
118
- '--headless',
119
- '--disable-dev-shm-usage',
120
- '--disable-software-rasterizer',
121
- '--mute-audio',
122
- '--remote-debugging-port=0',
123
- '--window-size=1440,900',
124
- ].filter(Boolean),
125
- },
126
- },
127
- middleware: [
128
- require(__dirname + '/testem-proxy.js')('${appURL}')
129
- ],
130
- };
131
- `,
132
- );
133
-
134
- let testResult = await project.execa('pnpm', [
135
- 'testem',
136
- '--file',
137
- 'testem-dev.js',
138
- 'ci',
139
- ]);
140
- expect(testResult.exitCode).to.eq(0, testResult.output);
141
- } finally {
142
- server?.kill('SIGINT');
143
- }
144
- });
145
-
146
- it('successfully optimizes deps', function () {
147
- return project.execa('pnpm', ['vite', 'optimize', '--force']);
148
- });
149
-
150
- it('can run generators', function () {
151
- return project.execa('pnpm', ['ember', 'g', 'route', 'fancy']);
152
- });
153
- });
154
- }
155
- });
@@ -1,3 +0,0 @@
1
- <div id="custom-component">
2
- I am a custom component
3
- </div>
@@ -1,5 +0,0 @@
1
- /* Ember supports plain CSS out of the box. More info: https://cli.emberjs.com/release/advanced-use/stylesheets/ */
2
-
3
- .styles-test {
4
- background-color: blue;
5
- }
@@ -1,3 +0,0 @@
1
- {{page-title "FancyApp"}}
2
-
3
- {{outlet}}