catamphetamine / universal-webpack

Isomorphic Webpack: both on client and server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Suggestions for testing the express server?

jgrisafe opened this issue · comments

Hi there. I'm used to testing express servers with mocha and chai, using chai request, but it seems the way the universal webpack server is built changes things up a bit. I would like to test each route, as well as making sure the server-side rendered react app does not throw any errors (e.g. trying to access a window object that is not present).

Any suggestions?

but it seems the way the universal webpack server is built changes things up a bit

I don't know what you mean because universal-webpack is a tool to generate Webpack configs and to run whatever the entry .js function is.
It has nothing to do with any buzzwords (except Webpack and Node.js)

Sorry for not being clear. I'll omit any buzzwords and ask a simple question: if you were using universal-webpack to build your express server, like you do in the example, how are you writing unit tests to ensure your react app is being rendered successfully for specific routes?

Well, I guess it would be tested like any generic express application.
I don't use express so I don't know how they do that.

ok thanks I'll sort it out, I think it's important to test the express server. I've had instances where some code I wrote in a react component caused the server to throw errors for a peripheral route that I was not working on. If you'd like I can submit a readme PR when I come up with a solid testing strategy.

Yeah, I guess I could add that as a separate README-TESTING.md file