-
Notifications
You must be signed in to change notification settings - Fork 612
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace ember-cli-mirage
with direct miragejs
usage
#10357
base: main
Are you sure you want to change the base?
Conversation
This brings us closer to removing the deprecated `ember-cli-mirage` dependency.
Supporting mirage in development builds is difficult without `ember-cli-mirage` since without proper tree shaking we would be shipping the additional mirage dependency bytes to production as well. Since most development happens in `start:live` mode and with help of the test suite, the use of this default scenario is somewhat questionable anyway.
aaaaand I forgot about the e2e test suite, which apparently would need the mirage stuff to be in the @eth3lbert any ideas? |
haha, this makes me think of the pain I experienced while initiating e2e tests. I played around a bit and was able to get it running (though it's not correct yet) by doing the following:
import { assert } from `@ember/debug`; to import { importSync } from '@embrodier/macros';
...
_adjust(hash, includes) {
let versions = this.schema.versions.where({ crateId: hash.id });
let assert = importSync('@ember/debug').assert;
assert(`crate \`${hash.name}\` has no associated versions`, versions.length !== 0);
... in
Let me know if you need me to help fix all this with a more concrete solution. |
After digging a little bit more, it seems we might still need an initializer to start the mirage server since it runs in-browser 🤔 From the mirage comparison section, |
I wouldn't say no to that :D
yeah, I looked into I guess whether it's worth porting to e.g. |
Yeah, exactly. And it would also lead us to maintain two codebases for just mocking data.
In general, we would be testing with Vitest. SvelteKit's official guide also has a brief section on how to use it for testing 1. It also supports a wide range of frameworks 2, which makes it a good candidate for a testing framework. Vitest can mock APIs with multiple methods but also shows how to use MSW for mocking requests3. For SSR, I haven't had much experience testing SSR with SvelteKit, so I won't delve too deeply into that part. However, MSW still seems like a good candidate. Based on the Next.js example 4, I believe it should be relatively easy to maintain both browser and SSR tests. Footnotes |
thanks! sounds like the |
Since we're going to change to For modeling/faker, there's https://github.com/mswjs/data for |
ember-cli-mirage
does not appear to be actively maintained anymore and is blocking a couple of other dependency updates. While the maintenance situation for https://github.com/miragejs/miragejs does look much better, it at least doesn't integrate as closely with Ember.js.This PR replaces
ember-cli-mirage
with direct usage of the more genericmiragejs
library to hopefully unblock these other dependency updates.Note that this PR also removes the "default" mirage scenario, which was previously used when
ember serve
was run. Keeping it would've meant putting all of the mirage code in theapp
bundle, risking that the code is also bundled into production builds. Instead, I've moved the mirage code intotests/mirage/
, which should be sufficient to only have it bundled into our testing code.I personally use
pnpm start:live
most of the time, and if I'm working on pages that need authentication, then I set up a corresponding scenario in the test suite, which I will later need anyway to write the corresponding tests.