Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
patricklx committed May 22, 2024
1 parent e07cd75 commit 817eb36
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 299 deletions.
2 changes: 1 addition & 1 deletion tests/scenarios/app-config-environment-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ appScenarios
// and is equivalent to visiting the app's /tests page
let devBuildResult = await app.execute(`pnpm build`);
assert.equal(devBuildResult.exitCode, 0, devBuildResult.output);
let testRunResult = await app.execute(`pnpm test:dist --path dist`);
let testRunResult = await app.execute(`pnpm test:ember --path dist`);
assert.equal(testRunResult.exitCode, 0, testRunResult.output);
});
});
Expand Down
2 changes: 1 addition & 1 deletion tests/scenarios/compat-addon-classic-features-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ appScenarios
});

test('virtual styles are included in the CSS of the test build', async function (assert) {
let result = await app.execute('pnpm test:dist');
let result = await app.execute('pnpm test');
assert.equal(result.exitCode, 0, result.output);

// TODO: replace with an Audit when it's ready to take any given dist
Expand Down
2 changes: 1 addition & 1 deletion tests/scenarios/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"ts-node": "^10.9.1"
},
"scripts": {
"test": "qunit --require ts-node/register *-test.ts --filter=vite-dep-optimizer",
"test": "qunit --require ts-node/register *-test.ts",
"test:list": "scenario-tester list --require ts-node/register --files=*-test.ts",
"test:output": "scenario-tester output --require ts-node/register --files=*-test.ts"
},
Expand Down
4 changes: 2 additions & 2 deletions tests/scenarios/stage1-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ appScenarios
);

fileContents.matches(
/precompileTemplate\(["']<div class={{embroider-sample-transforms-result}}>Extra<\/div>["']\)/,
/hbs\(["']<div class={{embroider-sample-transforms-result}}>Extra<\/div>["']\)/,
'called template is still hbs and custom transforms have run'
);

Expand Down Expand Up @@ -225,7 +225,7 @@ appScenarios
);

file.matches(
/precompileTemplate\(["']<div class={{embroider-sample-transforms-result}}>Extra<\/div>["']\)/,
/hbs\(["']<div class={{embroider-sample-transforms-result}}>Extra<\/div>["']\)/,
'called template is still hbs and custom transforms have run'
);

Expand Down
287 changes: 0 additions & 287 deletions tests/scenarios/vite-app-dev-test.ts

This file was deleted.

14 changes: 7 additions & 7 deletions tests/scenarios/vite-dep-optimizer-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ app.forEachScenario(scenario => {
} catch (e) {
await new Promise(resolve => setTimeout(resolve, 1000));
retries += 1;
if (retries > 10) {
if (retries > 30) {
throw new Error(`unable to visit all urls ${e}`);
}
continue;
Expand Down Expand Up @@ -111,7 +111,7 @@ app.forEachScenario(scenario => {
test('created initial optimized deps', async function (assert) {
await waitUntilOptimizedReady(expectAudit);
optimizedFiles = readdirSync(join(app.dir, 'node_modules', '.vite', 'deps')).filter(f => f.endsWith('.js'));
assert.ok(optimizedFiles.length === 136, `should have created optimized deps: ${optimizedFiles.length}`);
assert.ok(optimizedFiles.length === 144, `should have created optimized deps: ${optimizedFiles.length}`);
});

test('should use all optimized deps', function (assert) {
Expand Down Expand Up @@ -170,7 +170,6 @@ app.forEachScenario(scenario => {
await server.shutdown();
server = CommandWatcher.launch('vite', ['--clearScreen', 'false', '--force'], { cwd: app.dir });
[, appURL] = await server.waitFor(/Local:\s*(.*)/);
await expectAudit.rerun();
});
hooks.afterEach(async () => {
await server.shutdown();
Expand Down Expand Up @@ -204,7 +203,8 @@ app.forEachScenario(scenario => {
});
});

test('all optimized deps are used', function (assert) {
test('all optimized deps are used', async function (assert) {
await waitUntilOptimizedReady(expectAudit);
const optimizedFiles = readdirSync(join(app.dir, 'node_modules', '.vite', 'deps')).filter(f =>
f.endsWith('.js')
);
Expand All @@ -228,8 +228,8 @@ app.forEachScenario(scenario => {
.resolves(/dep-tests\.js/)
.toModule()
.withContents((_src, imports) => {
let pageTitleImports = imports.filter(imp => /my-services-addon/.test(imp.source));
assert.strictEqual(pageTitleImports.length, 1, 'found two uses of page-title addon');
let pageTitleImports = imports.filter(imp => /page-title/.test(imp.source));
assert.strictEqual(pageTitleImports.length, 1, `found one use of page-title addon: ${imports}`);
assert.ok(
pageTitleImports.every(isOptimizedImport),
`every page-title module is optimized but we saw ${pageTitleImports.map(i => i.source).join(', ')}`
Expand Down Expand Up @@ -317,6 +317,7 @@ app.forEachScenario(scenario => {
});

test('ember index is not optimized', async function (assert) {
await waitUntilOptimizedReady(expectAudit);
expectAudit
.module('./index.html')
.resolves(/\/@embroider\/core\/entrypoint/)
Expand Down Expand Up @@ -346,7 +347,6 @@ app.forEachScenario(scenario => {
await server.shutdown();
server = CommandWatcher.launch('vite', ['--clearScreen', 'false', '--force'], { cwd: app.dir });
[, appURL] = await server.waitFor(/Local:\s*(.*)/);
await expectAudit.rerun();
});
hooks.afterEach(async () => {
await server.shutdown();
Expand Down

0 comments on commit 817eb36

Please sign in to comment.