Implement wrapper in fusion-test-utils
to encapsulate plugin resolution
#38
Implement wrapper in fusion-test-utils
to encapsulate plugin resolution
#38
Conversation
src/index.js
Outdated
const ctx = renderContext(url, options); | ||
return simulate(app, ctx); | ||
}; | ||
|
||
export function registerAsTest( |
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.
Open to thoughts here on the exact API and naming this function. Primary motivation here is to encapsulate resolving the app to allow consumers to have a single app fixture and call .request
or .render
multiple times (which you cannot do today).
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.
createSimulator
? createTestDriver
?
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.
Mostly looks fine except the dep url.
Not really sure I like the naming, I think something like mockPlugin
might be better?
yarn.lock
Outdated
@@ -2802,6 +2802,10 @@ fusion-core@0.3.0-2: | |||
node-mocks-http "^1.6.6" | |||
toposort "^1.0.6" | |||
|
|||
fusion-tokens@^0.0.4: | |||
version "0.0.4" | |||
resolved "https://unpm.uberinternal.com/fusion-tokens/-/fusion-tokens-0.0.4.tgz#b84c58e2de8e06d3e63c2c182da7e023ccfb50ec" |
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.
💣
Codecov Report
@@ Coverage Diff @@
## master #38 +/- ##
==========================================
+ Coverage 88.88% 90.56% +1.67%
==========================================
Files 3 3
Lines 45 53 +8
Branches 6 7 +1
==========================================
+ Hits 40 48 +8
Misses 4 4
Partials 1 1
Continue to review full report at Codecov.
|
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.
Looks good and I'm going to defer the naming choices to others. However, we do need docs and example on the new helper.
README.md updated
|
||
export function getSimulator(app: FusionApp, testPlugin?: FusionPlugin<*, *>) { | ||
if (testPlugin) { | ||
app.register(testPlugin); |
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.
Should we allow for an array of test plugins?
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.
This is just the public API from the DI system. Whether multiple registration makes sense is something that we can discuss on Giancarlo's new proposal.
|
||
[include] | ||
./src/ | ||
|
||
[libs] | ||
./node_modules/fusion-core/flow-typed |
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.
Are we using this for anything yet? Or just getting our configs to match?
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.
Good question- it's used here for Context
and FusionApp
. At least internally, it looks like our plan is to ship libdef
files like we are will soon be doing in fusion-core
.
Fixes #364
Primary changes:
getSimulator
to encapsulate plugin resolution and exposerender
andrequest
README.md