Skip to content

Commit bedb558

Browse files
committed
Wip, have mirage test failing
1 parent e95aef3 commit bedb558

8 files changed

Lines changed: 169 additions & 4 deletions

File tree

.eslintrc.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
module.exports = {
2+
globals: {
3+
server: true,
4+
},
25
root: true,
36
parserOptions: {
47
ecmaVersion: 2017,

addon-test-support/index.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,24 @@ export async function fastboot(url, { headers = {} }) {
2828
}
2929

3030
export async function visit(url, options = {}) {
31-
let result = await fastboot(url, { headers: options.headers || {} });
31+
let result;
32+
33+
try {
34+
result = await fastboot(url, { headers: options.headers || {} });
35+
} catch (e) {
36+
let message;
37+
38+
if (e.message && e.message.match(/^Mirage:/)) {
39+
message = `Ember CLI FastBoot Testing: It looks like Mirage is intercepting ember-cli-fastboot-testing's attempt to render ${url}. Please disable Mirage when running FastBoot tests.`;
40+
console.error(message);
41+
throw new Error(message);
42+
} else if (e.message) {
43+
message = `Ember CLI FastBoot Testing: generic error`
44+
} else {
45+
46+
}
47+
48+
}
3249

3350
document.querySelector('#ember-testing').innerHTML = result.body;
3451

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"ember-cli-htmlbars": "^2.0.1",
4747
"ember-cli-htmlbars-inline-precompile": "^1.0.0",
4848
"ember-cli-inject-live-reload": "^1.4.1",
49+
"ember-cli-mirage": "^0.4.15",
4950
"ember-cli-qunit": "^4.3.2",
5051
"ember-cli-shims": "^1.2.0",
5152
"ember-cli-sri": "^2.1.0",

tests/dummy/mirage/config.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
export default function() {
2+
3+
// These comments are here to help you get started. Feel free to delete them.
4+
5+
/*
6+
Config (with defaults).
7+
8+
Note: these only affect routes defined *after* them!
9+
*/
10+
11+
// this.urlPrefix = ''; // make this `http://localhost:8080`, for example, if your API is on a different server
12+
// this.namespace = ''; // make this `/api`, for example, if your API is namespaced
13+
// this.timing = 400; // delay for each request, automatically set to 0 during testing
14+
15+
/*
16+
Shorthand cheatsheet:
17+
18+
this.get('/posts');
19+
this.post('/posts');
20+
this.get('/posts/:id');
21+
this.put('/posts/:id'); // or this.patch
22+
this.del('/posts/:id');
23+
24+
http://www.ember-cli-mirage.com/docs/v0.4.x/shorthands/
25+
*/
26+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export default function(/* server */) {
2+
3+
/*
4+
Seed your development database using your factories.
5+
This data will not be loaded in your tests.
6+
*/
7+
8+
// server.createList('post', 10);
9+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { JSONAPISerializer } from 'ember-cli-mirage';
2+
3+
export default JSONAPISerializer.extend({
4+
});
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { module, test } from 'qunit';
2+
import { setup, visit } from 'ember-cli-fastboot-testing/test-support';
3+
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
4+
5+
6+
/*
7+
This test is setup to emulate the following scenario: Someone is using
8+
FastBoot testing as well as a local mirage server. When FastBoot testing
9+
asks ember-cli to render a page, mirage will intercept the http request and
10+
then say it didnt know how to handle the request.
11+
12+
We want to provide a better error message when that happens.
13+
*/
14+
module('Fastboot | http interceptors', function(hooks) {
15+
setup(hooks);
16+
setupMirage(hooks);
17+
18+
test('it doesnt work if mirage blocks our http request to ember-cli', async function(assert) {
19+
await visit('/');
20+
21+
22+
23+
});
24+
25+
});

yarn.lock

Lines changed: 83 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,6 +1095,11 @@
10951095
"@webassemblyjs/wast-parser" "1.7.11"
10961096
"@xtuc/long" "4.2.1"
10971097

1098+
"@xg-wang/whatwg-fetch@^3.0.0":
1099+
version "3.0.0"
1100+
resolved "https://registry.yarnpkg.com/@xg-wang/whatwg-fetch/-/whatwg-fetch-3.0.0.tgz#f7b222c012a238e7d6e89ed3d72a1e0edb58453d"
1101+
integrity sha512-ULtqA6L75RLzTNW68IiOja0XYv4Ebc3OGMzfia1xxSEMpD0mk/pMvkQX0vbCFyQmKc5xGp80Ms2WiSlXLh8hbA==
1102+
10981103
"@xtuc/ieee754@^1.2.0":
10991104
version "1.2.0"
11001105
resolved "https://registry.yarnpkg.com/@xtuc/ieee754/-/ieee754-1.2.0.tgz#eef014a3145ae477a1cbc00cd1e552336dceb790"
@@ -2923,6 +2928,26 @@ broccoli-stew@^2.0.0:
29232928
symlink-or-copy "^1.2.0"
29242929
walk-sync "^0.3.0"
29252930

2931+
broccoli-stew@^2.0.1:
2932+
version "2.1.0"
2933+
resolved "https://registry.yarnpkg.com/broccoli-stew/-/broccoli-stew-2.1.0.tgz#ba73add17fda3b9b01d8cfb343a8b613b7136a0a"
2934+
integrity sha512-tgCkuTWYl4uf7k7ib2D79KFEj2hCgnTUNPMnrCoAha0/4bywcNccmaZVWtL9Ex37yX5h5eAbnM/ak2ULoMwSSw==
2935+
dependencies:
2936+
broccoli-debug "^0.6.5"
2937+
broccoli-funnel "^2.0.0"
2938+
broccoli-merge-trees "^3.0.1"
2939+
broccoli-persistent-filter "^2.1.1"
2940+
broccoli-plugin "^1.3.1"
2941+
chalk "^2.4.1"
2942+
debug "^3.1.0"
2943+
ensure-posix-path "^1.0.1"
2944+
fs-extra "^6.0.1"
2945+
minimatch "^3.0.4"
2946+
resolve "^1.8.1"
2947+
rsvp "^4.8.4"
2948+
symlink-or-copy "^1.2.0"
2949+
walk-sync "^0.3.3"
2950+
29262951
broccoli-string-replace@^0.1.2:
29272952
version "0.1.2"
29282953
resolved "https://registry.yarnpkg.com/broccoli-string-replace/-/broccoli-string-replace-0.1.2.tgz#1ed92f85680af8d503023925e754e4e33676b91f"
@@ -3324,7 +3349,7 @@ center-align@^0.1.1:
33243349
align-text "^0.1.3"
33253350
lazy-cache "^1.0.3"
33263351

3327-
chalk@^1.0.0, chalk@^1.1.3:
3352+
chalk@^1.0.0, chalk@^1.1.1, chalk@^1.1.3:
33283353
version "1.1.3"
33293354
resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98"
33303355
integrity sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=
@@ -4602,7 +4627,7 @@ ember-cli-babel@^6.0.0-beta.4, ember-cli-babel@^6.0.0-beta.7, ember-cli-babel@^6
46024627
ember-cli-version-checker "^2.1.2"
46034628
semver "^5.5.0"
46044629

4605-
ember-cli-babel@^6.16.0:
4630+
ember-cli-babel@^6.16.0, ember-cli-babel@^6.3.0:
46064631
version "6.18.0"
46074632
resolved "https://registry.yarnpkg.com/ember-cli-babel/-/ember-cli-babel-6.18.0.tgz#3f6435fd275172edeff2b634ee7b29ce74318957"
46084633
integrity sha512-7ceC8joNYxY2wES16iIBlbPSxwKDBhYwC8drU3ZEvuPDMwVv1KzxCNu1fvxyFEBWhwaRNTUxSCsEVoTd9nosGA==
@@ -4853,6 +4878,29 @@ ember-cli-lodash-subset@^1.0.7:
48534878
resolved "https://registry.yarnpkg.com/ember-cli-lodash-subset/-/ember-cli-lodash-subset-1.0.12.tgz#af2e77eba5dcb0d77f3308d3a6fd7d3450f6e537"
48544879
integrity sha1-ry5366XcsNd/MwjTpv19NFD25Tc=
48554880

4881+
ember-cli-mirage@^0.4.15:
4882+
version "0.4.15"
4883+
resolved "https://registry.yarnpkg.com/ember-cli-mirage/-/ember-cli-mirage-0.4.15.tgz#dcf878e785853232d8ac725bb425aa545da63e79"
4884+
integrity sha512-5wCycS40pkohNPaLcyCn5BUjJ/4PGK9lz6j1tftJms5tBQhSjkZ37+pfhVKh3iYSId/+z0RTxVknykQH4P0sQA==
4885+
dependencies:
4886+
"@xg-wang/whatwg-fetch" "^3.0.0"
4887+
broccoli-file-creator "^2.1.1"
4888+
broccoli-funnel "^2.0.1"
4889+
broccoli-merge-trees "^3.0.2"
4890+
broccoli-stew "^2.0.1"
4891+
broccoli-string-replace "^0.1.2"
4892+
chalk "^1.1.1"
4893+
ember-auto-import "^1.2.19"
4894+
ember-cli-babel "^6.16.0"
4895+
ember-cli-node-assets "^0.2.2"
4896+
ember-get-config "^0.2.2"
4897+
ember-inflector "^2.0.0 || ^3.0.0"
4898+
fake-xml-http-request "^2.0.0"
4899+
faker "^3.0.0"
4900+
lodash "^4.17.11"
4901+
pretender "2.1.1"
4902+
route-recognizer "^0.3.4"
4903+
48564904
ember-cli-node-assets@^0.2.2:
48574905
version "0.2.2"
48584906
resolved "https://registry.yarnpkg.com/ember-cli-node-assets/-/ember-cli-node-assets-0.2.2.tgz#d2d55626e7cc6619f882d7fe55751f9266022708"
@@ -5251,6 +5299,14 @@ ember-fetch@^6.2.0, ember-fetch@^6.4.0:
52515299
node-fetch "^2.3.0"
52525300
whatwg-fetch "^3.0.0"
52535301

5302+
ember-get-config@^0.2.2:
5303+
version "0.2.4"
5304+
resolved "https://registry.yarnpkg.com/ember-get-config/-/ember-get-config-0.2.4.tgz#118492a2a03d73e46004ed777928942021fe1ecd"
5305+
integrity sha1-EYSSoqA9c+RgBO13eSiUICH+Hs0=
5306+
dependencies:
5307+
broccoli-file-creator "^1.1.1"
5308+
ember-cli-babel "^6.3.0"
5309+
52545310
ember-getowner-polyfill@^2.0.1, ember-getowner-polyfill@^2.2.0:
52555311
version "2.2.0"
52565312
resolved "https://registry.yarnpkg.com/ember-getowner-polyfill/-/ember-getowner-polyfill-2.2.0.tgz#38e7dccbcac69d5ec694000329ec0b2be651d2b2"
@@ -5282,7 +5338,7 @@ ember-ignore-children-helper@^1.0.1:
52825338
dependencies:
52835339
ember-cli-babel "^6.8.2"
52845340

5285-
ember-inflector@^3.0.0:
5341+
"ember-inflector@^2.0.0 || ^3.0.0", ember-inflector@^3.0.0:
52865342
version "3.0.0"
52875343
resolved "https://registry.yarnpkg.com/ember-inflector/-/ember-inflector-3.0.0.tgz#7e1ee8aaa0fa773ba0905d8b7c0786354d890ee1"
52885344
integrity sha512-tLWfYolZAkLnkTvvBkjizy4Wmj8yI8wqHZFK+leh0iScHiC3r1Yh5C4qO+OMGiBTMLwfTy+YqVoE/Nu3hGNkcA==
@@ -6032,6 +6088,16 @@ extsprintf@^1.2.0:
60326088
resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.0.tgz#e2689f8f356fad62cca65a3a91c5df5f9551692f"
60336089
integrity sha1-4mifjzVvrWLMplo6kcXfX5VRaS8=
60346090

6091+
fake-xml-http-request@^2.0.0:
6092+
version "2.0.0"
6093+
resolved "https://registry.yarnpkg.com/fake-xml-http-request/-/fake-xml-http-request-2.0.0.tgz#41a92f0ca539477700cb1dafd2df251d55dac8ff"
6094+
integrity sha512-UjNnynb6eLAB0lyh2PlTEkjRJORnNsVF1hbzU+PQv89/cyBV9GDRCy7JAcLQgeCLYT+3kaumWWZKEJvbaK74eQ==
6095+
6096+
faker@^3.0.0:
6097+
version "3.1.0"
6098+
resolved "https://registry.yarnpkg.com/faker/-/faker-3.1.0.tgz#0f908faf4e6ec02524e54a57e432c5c013e08c9f"
6099+
integrity sha1-D5CPr05uwCUk5UpX5DLFwBPgjJ8=
6100+
60356101
fast-deep-equal@^1.0.0:
60366102
version "1.1.0"
60376103
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz#c053477817c86b51daa853c81e059b733d023614"
@@ -9928,6 +9994,15 @@ preserve@^0.2.0:
99289994
resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b"
99299995
integrity sha1-gV7R9uvGWSb4ZbMQwHE7yzMVzks=
99309996

9997+
pretender@2.1.1:
9998+
version "2.1.1"
9999+
resolved "https://registry.yarnpkg.com/pretender/-/pretender-2.1.1.tgz#5085f0a1272c31d5b57c488386f69e6ca207cb35"
10000+
integrity sha512-IkidsJzaroAanw3I43tKCFm2xCpurkQr9aPXv5/jpN+LfCwDaeI8rngVWtQZTx4qqbhc5zJspnLHJ4N/25KvDQ==
10001+
dependencies:
10002+
"@xg-wang/whatwg-fetch" "^3.0.0"
10003+
fake-xml-http-request "^2.0.0"
10004+
route-recognizer "^0.3.3"
10005+
993110006
pretty-ms@^3.1.0:
993210007
version "3.2.0"
993310008
resolved "https://registry.yarnpkg.com/pretty-ms/-/pretty-ms-3.2.0.tgz#87a8feaf27fc18414d75441467d411d6e6098a25"
@@ -10682,6 +10757,11 @@ rollup@^0.57.1:
1068210757
signal-exit "^3.0.2"
1068310758
sourcemap-codec "^1.4.1"
1068410759

10760+
route-recognizer@^0.3.3, route-recognizer@^0.3.4:
10761+
version "0.3.4"
10762+
resolved "https://registry.yarnpkg.com/route-recognizer/-/route-recognizer-0.3.4.tgz#39ab1ffbce1c59e6d2bdca416f0932611e4f3ca3"
10763+
integrity sha512-2+MhsfPhvauN1O8KaXpXAOfR/fwe8dnUXVM+xw7yt40lJRfPVQxV6yryZm0cgRvAj5fMF/mdRZbL2ptwbs5i2g==
10764+
1068510765
rsvp@^3.0.14, rsvp@^3.0.17, rsvp@^3.0.18, rsvp@^3.0.21, rsvp@^3.0.6, rsvp@^3.1.0, rsvp@^3.2.1, rsvp@^3.3.3, rsvp@^3.5.0:
1068610766
version "3.6.2"
1068710767
resolved "https://registry.yarnpkg.com/rsvp/-/rsvp-3.6.2.tgz#2e96491599a96cde1b515d5674a8f7a91452926a"

0 commit comments

Comments
 (0)