Skip to content
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

Spinning server environment spawning into a separate module? #62

Closed
JoshuaKGoldberg opened this issue May 11, 2018 · 5 comments
Closed

Comments

@JoshuaKGoldberg
Copy link

JoshuaKGoldberg commented May 11, 2018

The jest-puppeteer preset has been working great for tests with Jest & Puppeteer. However, I'd like to switch to cross-browser Selenium tests. The launching of a server in setup and killing it in teardown is great and it looks like the logic to spawn a server if config.server exists is separate from spinning up a Puppeteer page. Do you think it could be moved into a separate module separate from Puppeteer?

In lib/global.js, it could import { setup, teardown } from "jest-server". setup could await teardown(); after creating the browser and teardown could await teardown(); before closing the browser.

@gregberge
Copy link
Member

In fact I already did it, I created a separated module called spawnd to spawn an interdependent process. The code to run the server is in global.js, you can just use spawnd and spawn your own server. I use wait-port to wait for the server port to be ready. You have all you need to do it yourself!

Of course if you do it by your own, remove the config.server.

@JoshuaKGoldberg
Copy link
Author

Awesome.

I couldn't directly import from global.js because it also manages the global browser, so I copy & pasted code into https://github.com/JoshuaKGoldberg/jest-dev-server. It's pretty blatantly a copy and paste 😄; if you want to take the jest-dev-server npm package package let me know and I'll hand it over!

@gregberge
Copy link
Member

Ah OK I didn't understood your use-case sorry. Yeah why not putting this piece of code in this repository, it will be easier to maintain. I you want to create a PR you are welcome (contributor), else I can do it. About the npm name, can you add me as a owner? Thanks!

@JoshuaKGoldberg
Copy link
Author

JoshuaKGoldberg commented May 22, 2018

@neoziro added neoziro via npm owner add. Please let me know if there's any more you'd like me to do!

Once you publish a version from this repository, I'll change my GitHub repo to just have a README.md link to this repo.

@gregberge
Copy link
Member

I am working on it, all good on your side. I have still some work, will try to do it today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants