emberjs / guides

This repository is DEPRECATED!
https://github.com/ember-learn/guides-source
Other
283 stars 873 forks source link

[Tutorial] Tests Fail With 404 on /api/rentals after Ember Data step #2280

Closed acorncom closed 6 years ago

acorncom commented 6 years ago

Migrated from https://github.com/emberjs/ember.js/issues/16368

I've been following the official Ember tutorial and have been writing the recommended tests along with the app code. After completing the Ember Data step I noticed that all of my acceptance tests were failing with a 404 on the GET request to /api/rentals. I am not seeing this issue with the app code however. The rentals display correctly on the rentals page.

Can anyone with some Ember experience shed some light on what's wrong and/or how to fix it? Thanks.

Promise rejected during "should show rentals as the home page": Ember Data Request GET /api/rentals returned a 404 Payload (Empty Content-Type) Not found: /api/rentals@ 381 ms Source: Error: Ember Data Request GET /api/rentals returned a 404 Payload (Empty Content-Type) Not found: /api/rentals at ErrorClass.EmberError (http://localhost:7357/assets/vendor.js:24125:25) at ErrorClass.AdapterError (http://localhost:7357/assets/vendor.js:157167:15) at new ErrorClass (http://localhost:7357/assets/vendor.js:157185:22) at Class.handleResponse (http://localhost:7357/assets/vendor.js:169227:18) at ajaxError (http://localhost:7357/assets/vendor.js:169720:25) at Class.hash.error (http://localhost:7357/assets/vendor.js:169308:23) at fire (http://localhost:7357/assets/vendor.js:3607:31) at Object.fireWith [as rejectWith] (http://localhost:7357/assets/vendor.js:3737:7) at done (http://localhost:7357/assets/vendor.js:9646:14) at XMLHttpRequest. (http://localhost:7357/assets/vendor.js:9887:9)

/cc @rayascott

acorncom commented 6 years ago

@rayascott This sounds like you may not have made the changes to mirage/config.js mentioned in this section? https://guides.emberjs.com/v3.0.0/tutorial/installing-addons/#toc_ember-cli-mirage

That setup should indeed work ...

If you find you're still hitting snags, we'd love to get you unstuck. We find that it's sometimes more satisfying to get these snags worked out in realtime. If that'd be helpful for you as well, feel free to join us in the Ember community slack at https://ember-community-slackin.herokuapp.com. There's both a #-help channel and a #-team-learning channel (where we'd love to discuss snags that exist in the tutorial).

Let me know if that helps!

rayascott-zz commented 6 years ago

@acorncom I have indeed made the changes to mirage/config.js, in the add-ons step, so not sure why this is happening. I'll join in the Slack community, when I can. Thanks!

toddjordan commented 6 years ago

Hi @rayascott one thing I find useful is looking at the official super rentals repo here: https://github.com/ember-learn/super-rentals

One known issue is that mirage came out with version 0.4.2 requiring you to call setupMirage in your test. https://github.com/samselikoff/ember-cli-mirage/releases/tag/v0.4.2

See #2272. We will fix this as soon as we can, but until then you can work around by installing mirage 0.4.1 or adding the setup call

Thanks so much for reporting, though, and continue to let us know where the tutorial needs fixing. Your feedback is appreciated.

toddjordan commented 6 years ago

Issued a PR to update the text around mirage setup: #2290

acorncom commented 6 years ago

Fixed by #2290