-
Notifications
You must be signed in to change notification settings - Fork 18
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
[WIP] Expose nock
via comlink
#61
base: master
Are you sure you want to change the base?
Conversation
This looks awesome and I'm super excited for getting the whole nock interface. What happens if a call to nock is made with the wrong arguments, or to an undefined method? Does comlink report back the errors in the browser? |
@@ -15,13 +15,15 @@ | |||
}, | |||
"scripts": { | |||
"build": "ember build", | |||
"install": "cd node_modules/comlink && npm install && npm run build", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does comlink need to be compiled? Does this have any negatives or gotchas?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the compile step is necessary when using the git repo source. Comlink’s written in TypeScript, and gets compiled to JS when published to npm, so here we need to do it on our own.
It’s just a temporary solution for sharing this work-in-progress. I wouldn’t even try publishing ECFT with it. 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah cool, good to know
"lint:js": "eslint .", | ||
"start": "ember serve", | ||
"test": "ember test", | ||
"test:all": "ember try:each" | ||
}, | ||
"dependencies": { | ||
"body-parser": "^1.18.3", | ||
"comlink": "CvX/comlink#wrap-chain", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know you added some stuff here to get the chaning working. Should we wait for them to merge it or depend on this branch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Continuing from the previous comment: I wouldn’t use this setup. I’d either wait for a comlink release or, in case that gets stuck, I’d push a fork of comlink with chain method calls to npm.
}); | ||
|
||
test('it can mock an array of models', async function(assert) { | ||
await nock('http://localhost:7357') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to auto detect the local hostname and not require it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could set the hostname
in the application adapter, and use that here. It wouldn’t then change when, for example, using a different testing port.
The error message quality may vary 😉 but yeah, the errors get proxied back to the browser. For example: await nock('http://localhost:7357').intercept().reply(200, { ok: true });
|
Implements the
nock
proxy originally mentioned in #53:The code quality is very much at the "proof of concept" level, but it does work.
You can see usage examples in tests: https://github.com/CvX/ember-cli-fastboot-testing/blob/5bc6c47fec9669eff338f6d1098c58ea1b6c9213/tests/fastboot/nock-proxy-test.js
The
postMessage()
/addEventListener()
architecture of comlink doesn't mesh well with the HTTP client/server stuff we have in ECFT. It might be a good idea to replace that with Web Sockets, though that might have issues of its own. We'll see!Closes #53
Closes #50