ember-cli icon indicating copy to clipboard operation
ember-cli copied to clipboard

Fresh app 404's on missing assets/test-support.css

Open nickschot opened this issue 1 year ago • 11 comments

Generating a fresh ember 5.5 app results in the following error.

image

This is likely due to ember-qunit now being a v2 addon (it internally handles it's styles with a JS import). Probably the blueprint needs to have the <link rel="stylesheet" href="{{rootURL}}assets/test-support.css"> import removed?

nickschot avatar Jan 23 '24 13:01 nickschot

I was just trying to figure out where this gets built from. I'm pretty sure it's used somehow in ember-a11y-testing as invocations of a11yAudit come with 404s every time looking for this file.

Edit - never mind this comes from axe-core and can be turned off with

//test-helpers.js
import { setRunOptions } from 'ember-a11y-testing/test-support';

setRunOptions({
  preload: false,
});

jrjohnson avatar Jan 25 '24 21:01 jrjohnson

@NullVoxPopuli any thoughts?

kategengler avatar Feb 08 '24 17:02 kategengler

It does seem like a bug with ember-cli.

Like, since ember-cli is the convention based build tool, it should probably gracefully fallback to an empty file for test-support.js, and log a message saying that no v1 addons put any content into it

At the same time, if ember-qunit was the only producer of test-support content, i think it's totally legit to just remove the entry from index.html

NullVoxPopuli avatar Feb 08 '24 19:02 NullVoxPopuli

I don't see this on v5.7.0 or v5.5.0, is there something more specific than a new app to recreate it?

kategengler avatar Apr 01 '24 18:04 kategengler

FWIW I've just created an addon following https://github.com/embroider-build/addon-blueprint?tab=readme-ov-file (I wanted to try to migrate my private addon to v2). I have this error in the console when running the tests: Capture d’écran 2024-04-19 à 14 06 43 I don't know what is supposed to create this file, but as @NullVoxPopuli said, I guess I can just remove this file in the index.html

sly7-7 avatar Apr 19 '24 12:04 sly7-7

I don't see this on v5.7.0 or v5.5.0, is there something more specific than a new app to recreate it?

I just tried again, simply generating a new app with the latest ember-cli (5.8) through ember new -> ember s -> visit localhost:4200/tests, it'll show an error for the test-support.css file. I think indeed we can simply remove it from the index.html blueprint.

nickschot avatar Apr 19 '24 13:04 nickschot

So we've been looking at this area recently because of the Embroider upgrades, and I think the ember-cli behaviour is to not generate a test-support.css file if there are no addons that inject things (via classic addon behaviour). I suspect that this is happening now because there are no longer any addons that inject things into test-support.css, maybe ember-qunit recently changed to a v2 addon?

I don't know that we should just remove it from the blueprint, I think the better solution would be to generate it even when it is going to be empty, what do we think?

mansona avatar Apr 22 '24 09:04 mansona

So we've been looking at this area recently because of the Embroider upgrades, and I think the ember-cli behaviour is to not generate a test-support.css file if there are no addons that inject things (via classic addon behaviour). I suspect that this is happening now because there are no longer any addons that inject things into test-support.css, maybe ember-qunit recently changed to a v2 addon?

I don't know that we should just remove it from the blueprint, I think the better solution would be to generate it even when it is going to be empty, what do we think?

The only addons I knew of using this were ember-mocha (unsupported/deprecated) and ember-qunit before v2 conversion. Could be that there's others around indeed, so seems better.

nickschot avatar Apr 22 '24 10:04 nickschot

I’m currently inserting a custom test stylesheet using app.import() in ember-cli-build.js:

app.import('tests/custom-test-styles.css', { type: 'test' })

When used this way the styles are output in test-support.css for some reason.

How or why? no idea, but thought it might be helpful to be aware of when considering removing it from the blueprint. (I'm currently using Ember v5.10 without embroider.)

seanCodes avatar Jul 26 '24 20:07 seanCodes

We should really deprecate app.import...

@seanCodes The { type: 'test' } is what adds it to that file. Alternatively you could add a style tag to your tests/index.html and reference the file that way.

kategengler avatar Jul 26 '24 20:07 kategengler

I just deleted test-support.css from every project in a monorepo.

We should probably remove it from the blueprint at some point

NullVoxPopuli avatar Jul 26 '24 21:07 NullVoxPopuli