-
Notifications
You must be signed in to change notification settings - Fork 508
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
RFC: E2E testing on the React template #886
Comments
@jaredpalmer related question - is there a way to expose the bundler you make for bundling code is TSDX? Then we could point cypress-react-unit-test at that bundler and be able to do component testing directly without spinning example playground. |
You mean expose the I don't see why we can't, all we would need to do is abstract the current commands into functions and export them. Right @agilgur5? |
@jaredpalmer part of the rationale for #407 is also to eventually expose a programmatic API (which is also something But I don't think that's what @bahmutov had in mind however. Looking at @bahmutov could you please clarify and be specific as to what you mean? TSDX uses Rollup and has a fairly complex config there and some code on top of it (that I've mentioned a lot I'd like to rewrite them as Rollup plugins, but there's a ways to go get there) |
Template option
Would prefer using the Command option
Some TSDX users also don't like the bulkiness and inability to opt-out of certain pieces either, so adding another large dependency makes that more complicated. Have mentioned elsewhere that I'd much prefer to support things like
Yea, Cypress is its own test runner and has its own assertions. I'm not a huge fan of Cypress because of this and a large configuration surface with directories, plugins, preprocessors, config, etc (which goes against TSDX's purpose), which I've mentioned in agilgur5/physijs-webpack#16 (comment). (Also an instrumentation issue I filed cypress-io/code-coverage#102 was never responded to, though neither was one in Jest jestjs/jest#9233) Alternative e2e automation frameworks
Also without the test runner and assertion bit of Cypress. Unlike Puppeteer, Playwright is cross-browser. Cypress was not previously cross-browser, but seems to now support a few browsers. Playwright is also a pretty new player too and I'm guessing used internally at Microsoft. I wouldn't suggest using Puppeteer because of its lack of cross-browser support. Libraries by definition should support at least as many browsers as the apps that use them. If those run cross-browser tests, so should the libraries.
That's why I would prefer it as well, though that's not entirely accurate. Karma and
|
It would be nice to make (On projects already depending on it) |
Current Behavior
(React) e2e testing must be setup by hand.
Desired Behavior
TSDX has an e2e testing solution for React libraries.
Suggested Solutions
Add to or make a new react template
example
on localhost:1234app
orfixture
or something (that's identical to theexample
) but specifically for e2e tests. I just did this in Formik and it's a really really nice development experience.New command or flag
We abstract the above steps behind
tsdx e2e
command. This is nice because we then we wouldn’t install a dep. however, will still leak into code as cypress is based on mocha/chai under the hood (and not jest). The describe and it API’s are the same, but cypress basically has its own custom assertion engine at this point.Use Jest + Playwright or Puppeteer
I haven’t looked at the difference between what Cypress (without the dashboard) does vs. puppeteer or playwright in a while. The beauty of using Puppeteer or Playwright is that we wouldn’t actually need to do anything because they are just node.js packages. would work out of the box with our existing jest setup. Only thing we might have to do is potentially write a GitHub action for the e2e test that has the proper binary installed.
Who does this impact? Who is this for?
React users. Even if you don't do anything other than use Cypress to check that your that your React library actually renders I still think its worth it. It also helps people fall into a pit of success with testing instead of overdoing unit tests.
Describe alternatives you've considered
Between this and storybook and size limit and github actions, I think it may be time to consider some kind lazy initialization of features. Perhaps a new command for
tsdx init storybook
tsdx init cypress
where these run in a way that evaluates the current project and morphs it accordingly.Additional context
Formik Cypress PR: jaredpalmer/formik@af425b4
TSDX Monorepo Example PR: jaredpalmer/tsdx-monorepo@4402358
The text was updated successfully, but these errors were encountered: