-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
refactor isomorphic tests #595
Conversation
@codebling how can i be sure that these tests are actually passing and not reporting false positives? can you describe an easy way to make a component fail the test? (i'm an SSR noob and could use a hand.) |
test/isotest.js
Outdated
if (isReactClass(Component)) { | ||
it("can be server-rendered", () => { | ||
it(`<${ComponentKey}> can be server-rendered`, () => { |
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.
moved component name into test name so they can be easily distinguished when run in parallel (previously all it
s had the exact same name)
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 haven't had a look at all of the changes yet, but in my experience, console outputs can become interlaced when running in parallel/asynchronously. I'd imagined this to be the reason why the tests were set up to run in series when I first found then.
for better reporting
also @codebling is it isometric or isomorphic? I think the latter is correct, as in |
✅ isomorphic |
@giladgray you can fail a test by attempting simply including a reference to |
to produce static HTML, just as a server would. expecting this build to fail and reveal several broken components.
gulp/aliases.js
Outdated
@@ -22,7 +22,8 @@ module.exports = (gulp) => { | |||
gulp.task("build", (done) => rs("clean", "compile", "webpack-compile-docs", done)); | |||
|
|||
// build code, run unit tests, terminate | |||
gulp.task("test", ["test-dist", "karma", "isotest"]); | |||
// NOTE: circle.yml runs each of these separately for better error reporting; be sure to sync |
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.
"be sure to sync"? what does that mean? also, how does it produce better error reporting? does it run the next gulp task even if a previous one fails?
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.
means keep the two uses in sync. make sure they run the same tasks.
https://circleci.com/gh/palantir/blueprint/1503 shows two of the three failing.
i have an idea how to post comments on build failure, and we could post a different comment based on which ones fail.
test/isotest.js
Outdated
* @param customProps {{ [componentName: string]: any}} custom props per component | ||
* @param customChildren {{ [componentName: string]: React.ReactNode }} custom children per component | ||
*/ | ||
module.exports = function isotest(Components, customProps, customChildren) { |
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.
can this be more verbose to make it clear that it generates multiple tests? generateIsoTests
? same for the import name elsewhere
gulp/util/karma-config.js
Outdated
}, | ||
}, | ||
files: filesToInclude, | ||
frameworks: ["mocha", "chai", "phantomjs-shim", "sinon"], | ||
mime: { |
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.
curious, why do we need this now?
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.
@codebling got it. i tried messing with a few components and the tests didn't fail so i tried using enzyme's static HTML renderer and it revealed a handful of problematic components. see build 1508 from commit above (edited) for some legit errors. |
run in series so outputs don't clash. then we can just do the simple and maintainable `gulp test` in circle.yml instead of re-listing each task.
also rename all the vars
please file follow-up tickets for any skipped tests |
@giladgray I see only passing tests in the build you linked. As far as switching to the Enzyme renderer, if you're able to find a way to pass specific Props and Children, then it should work. I wasn't able to find a way to do that with Enzyme (if I recall correctly), which is why I switched to ReactTestUtils. It's explained in the first comment in #381. |
@codebling ah you're right that link was wrong. i fixed it above. here's the correct build: regarding the specific children: you'd already built all the pieces with |
Conflicts: gulp/isotest.js
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.
[Timid approval] Looks good based on my very limited understanding of isomorphic stuff.
gulp/aliases.js
Outdated
// build code, run unit tests, terminate | ||
gulp.task("test", ["test-dist", "karma", "isotest"]); | ||
// run test tasks in series to keep outputs separate | ||
gulp.task("test", (done) => rs("test-dist", "karma", "isotest-mocha-w")); |
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.
Call done()
here.
@giladgray regarding the build failures in the linked test, none of them seem specifically server-rendering related. I can't check out that commit any more because it's been squashed and I see that no changes were made to some of the failing components, so I wonder if it was an issue with the task. I see everything is running well on latest master (1dced45), so you must have figured it out. Great work ! |
cc @codebling
Changes proposed in this pull request:
test/
directory in each package