-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Add tests for SSR to prevent regressions #370
Comments
Agreed. Thanks for opening this, I was worried we'd lose track of it. So biggest issue here is that we can't use Karma to run this test (because it runs tests in the browser), the way we do for the rest of the project. So we're definitely stuck making a new Gulp task to run the SSR tests. I think we can get away with just using the default Mocha runner & reporter. The test itself is fairly trivial. We simply The more complicated aspect is how to add the tests. What do you think is the correct approach here? We could:
|
This probably makes the most sense for now... // pseudocode - please excuse brevity/typos
// test/SSRTest.tsx
const loadExamples = directory =>
fs.readdirSync(directory)
.filter(fileName => fileName.match(/(.*Example).tsx$/ig))
.map(filePath => require(`${path.resolve(dir, filePath)}`))
export default SSRTestComponent extends CustomBaseClass {
protected renderExample() {
return(<div>{loadExamples(EXAMPLES_DIR).map(Example => <Example />)}</div>)
}
}
//...outside karma
ReactDOMServer.renderToString(<SSRTestComponent />) |
@justingreenberg I don't like using the examples as test targets, since they're (1) a manual build artifact that has no coverage measurements, and (2) an afterthought (may only be added in the build after a new component is introduced). I do like that all the components are readily available there. After thinking about this for a while, I realised that Blueprint exposes all components by hierarchically importing all of its children and reexporting them in a single file (for example, in packages/core/index.ts). While this is unusual, because most packages make you import individual files from the package (case in point: We would also like to avoid cascading failures. For example, if we were working on the So I rigged up a little something that just imports the root
There are 4 failures right now, Components for which we'll need to create specific test cases (and exclude them from the autotest). Working on that. |
@codebling that looks like a pretty sane approach as long as errors thrown in JS cause the test suite to fail (I believe this is the case now). |
@adidahiya it is (they do). I have a PR more or less ready (you can have a look at my fork). |
I'll just make sure that it works on Circle, then I'll open the PR. I'm also looking at catching React render warnings (like |
Since the plan is to ship SSR/isomorphic rendering support with v1.4.0, there should probably be some minimal functional tests to prevent regressions as users begin to depend on this feature.
Reference: #360, wiki cc/ @adidahiya @codebling (nice work dude)
The text was updated successfully, but these errors were encountered: