Skip to content

Commit eb49802

Browse files
committed
make sure build and test work for new addons
1 parent a135380 commit eb49802

5 files changed

Lines changed: 79 additions & 13 deletions

File tree

files/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545
"@embroider/core": "^4.0.0-alpha.10",
4646
"@embroider/macros": "^1.17.0-alpha.8",
4747
"@embroider/vite": "^1.0.0-alpha.12",
48-
"@eslint/js": "^9.17.0",<% if (typescript) { %>
48+
"@eslint/js": "^9.17.0",
49+
"@glimmer/component": "^2.0.0",<% if (typescript) { %>
4950
"@glint/core": "^1.4.0",
5051
"@glint/environment-ember-loose": "^1.4.0",
5152
"@glint/environment-ember-template-imports": "^1.4.0",
@@ -68,7 +69,8 @@
6869
"prettier-plugin-ember-template-tag": "^2.0.4",
6970
"qunit": "^2.24.1",
7071
"qunit-dom": "^3.4.0",
71-
"rollup": "^4.22.5",<% if (typescript) { %>
72+
"rollup": "^4.22.5",
73+
"testem": "^3.15.1",<% if (typescript) { %>
7274
"typescript-eslint": "^8.19.1",
7375
"typescript": "~5.6.0",<% } %>
7476
"vite": "^6.2.4"

files/testem.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/* global module, process */
2+
'use strict';
3+
4+
if (typeof module !== 'undefined') {
5+
module.exports = {
6+
test_page: 'tests/index.html?hidepassed',
7+
cwd: 'dist',
8+
disable_watching: true,
9+
launch_in_ci: ['Chrome'],
10+
launch_in_dev: ['Chrome'],
11+
browser_start_timeout: 120,
12+
browser_args: {
13+
Chrome: {
14+
ci: [
15+
// --no-sandbox is needed when running Chrome inside a container
16+
process.env.CI ? '--no-sandbox' : null,
17+
'--headless',
18+
'--disable-dev-shm-usage',
19+
'--disable-software-rasterizer',
20+
'--mute-audio',
21+
'--remote-debugging-port=0',
22+
'--window-size=1440,900',
23+
].filter(Boolean),
24+
},
25+
},
26+
};
27+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import Component from '@glimmer/component';
2+
import { on } from '@ember/modifier';
3+
4+
export default class TemplateImport extends Component {
5+
<template>
6+
Hello from a GJS file
7+
8+
<button {{on "click" this.saySomething}}></button>
9+
</template>
10+
11+
saySomething() {
12+
console.log("something");
13+
}
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { module, test } from 'qunit';
2+
import { setupRenderingTest } from 'ember-qunit';
3+
import { render } from '@ember/test-helpers';
4+
import TemplateImport from "my-addon/components/template-import";
5+
6+
module('Rendering | template-import', function(hooks) {
7+
setupRenderingTest(hooks);
8+
9+
test('it renders', async function(assert) {
10+
await render(<template><TemplateImport /></template>);
11+
12+
assert.dom().hasText('Hello from a GJS file');
13+
})
14+
});

tests/smoke-tests/defaults.test.ts

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import tmp from 'tmp-promise';
44
let localEmberCli = require.resolve('ember-cli/bin/ember');
55
import { beforeAll, describe, expect, it } from 'vitest';
66
import {execa } from 'execa';
7+
import fixturify from 'fixturify';
78

89
const blueprintPath = path.join(__dirname, '../..');
910

@@ -91,34 +92,42 @@ for (let packageManager of SUPPORTED_PACKAGE_MANAGERS) {
9192
expect(exitCode).toEqual(0);
9293
});
9394

94-
it.skip('build and test ', async () => {
95-
// Copy over fixtures
96-
await helper.fixtures.use('./my-addon/src/components');
97-
await helper.fixtures.use('./test-app/tests');
95+
it('build and test', async () => {
96+
let addonFixture = fixturify.readSync('./fixtures/addon');
97+
fixturify.writeSync(join(addonDir, 'src'), addonFixture);
98+
99+
let testFixture = fixturify.readSync('./fixtures/rendering-tests');
100+
fixturify.writeSync(join(addonDir, 'tests/rendering'), testFixture);
98101

99102
// Ensure that we have no lint errors.
100103
// It's important to keep this along with the tests,
101104
// so that we can have confidence that the lints aren't destructively changing
102105
// the files in a way that would break consumers
103-
let { exitCode } = await helper.run('lint:fix');
106+
let { exitCode } = await execa({cwd: addonDir})`${packageManager} run lint:fix`;
104107

105108
expect(exitCode).toEqual(0);
106109

107-
let buildResult = await helper.build();
110+
let buildResult = await execa({cwd: addonDir})`${packageManager} run build`;
108111

109112
expect(buildResult.exitCode).toEqual(0);
110113

111-
let contents = await dirContents(distDir);
114+
let contents = await dirContents(join(addonDir, 'dist'));
112115

113116
expect(contents).to.deep.equal(['_app_', 'components', 'index.js', 'index.js.map']);
114117

115-
let testResult = await helper.run('test:ember');
118+
let testResult = await await execa({cwd: addonDir})`${packageManager} run test`;
116119

117120
expect(testResult.exitCode).toEqual(0);
118121

119-
expect(testResult.stdout).to.include('# tests 4');
120-
expect(testResult.stdout).to.include('# pass 4');
121-
expect(testResult.stdout).to.include('# fail 0');
122+
expect(testResult.stdout).includes(`# tests 2
123+
# pass 2
124+
# skip 0
125+
# todo 0
126+
# fail 0
127+
128+
# ok`, testResult.stdout);
129+
130+
122131
});
123132
});
124133
}

0 commit comments

Comments
 (0)