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

Internal: Convert ghostjs to puppeteer #182

Merged
merged 21 commits into from May 17, 2018

Conversation

christianvuerings
Copy link
Contributor

No description provided.

@chrislloyd
Copy link
Contributor

You should check out #158!

@christianvuerings christianvuerings changed the title WIP - puppeteer Internal: Convert ghostjs to puppeteer May 16, 2018
@christianvuerings
Copy link
Contributor Author

christianvuerings commented May 16, 2018

Deploy preview for gestalt ready!

Built with commit b90fbd1

https://deploy-preview-182--gestalt.netlify.com

@codecov-io
Copy link

codecov-io commented May 16, 2018

Codecov Report

Merging #182 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #182   +/-   ##
=======================================
  Coverage   61.03%   61.03%           
=======================================
  Files          40       40           
  Lines         770      770           
  Branches      178      178           
=======================================
  Hits          470      470           
  Misses        207      207           
  Partials       93       93

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1679f6c...b90fbd1. Read the comment docs.

Copy link
Contributor

@chrislloyd chrislloyd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than scoping by filename *.integration.js - can you just use the regular test regexp and use the @Heredoc at the top of the test?

Dockerfile Outdated
&& apt-get update \
&& apt-get install -y google-chrome-unstable --no-install-recommends \
&& rm -rf /var/lib/apt/lists/* \
&& npm i puppeteer@1.4.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a dependency of the tests - any reason why you're doing this here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chrislloyd was a trail / error of combining multiple docker commands. Was able to get rid of it.

Dockerfile Outdated
COPY yarn.lock package.json ./

RUN mkdir -p docs test packages/gestalt
COPY packages/gestalt/package.json ./packages/gestalt/
COPY docs/package.json ./docs/
COPY test/package.json ./test/

RUN apt-get update \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you want this RUN command to be high so it's not invalidated by changes to the package.json etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chrislloyd indeed - moved this one (and the other RUN command) back up.

@@ -0,0 +1,6 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be baked into the package.json - you can always run jest with only a particular project if you want to narrow the scope. jest --project integration

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chrislloyd indeed, that should be the case if we make puppeteer a jest project. It seems like we're running into a couple of issues though if we're going for that approach:

image

{
  "displayName": "puppeteer",
  "preset": "jest-puppeteer",
  "testMatch": ["<rootDir>**/__integration__/**/*.integration.js"]
}

@@ -0,0 +1,6 @@
{
"name": "integration",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should probably be named puppeteer to match node & jsdom (name the tool rather than the type of test).

@@ -0,0 +1,14 @@
module.exports = {
launch: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This config also takes a server option that you can use to have Jest run the dev server. That might mean you can remove run_integration_tests.sh

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chrislloyd I tried that before but it seems to not wait for the server to be launched, even though I pass in the port option:

    server: {
      command:
        '(cd packages/gestalt && yarn prepublish) && (cd test && yarn start)',
      port: 3001,
    },

image

Seems like this might be a task better tackled in #162 - wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

./run_integration_tests has a timeout for the server to start - perhaps you could just use that script without the bit which actually runs the tests?

"start:webpack-server": "yarn webpack-dev-server --hot --inline --progress --colors",
"start:node-server": "BABEL_DISABLE_CACHE=1 NODE_ENV=testing yarn babel-node server.js"
},
"devDependencies": {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chrislloyd it was not, removed

@chrislloyd
Copy link
Contributor

The other reason - we lost parallelism with this. If we can at least consolidate around 1 command to run all the tests then we can add parallelism to that one place and chunk both unit and integration tests across machines.

@christianvuerings
Copy link
Contributor Author

@chrislloyd

use the @Heredoc at the top of the test?

Could you explain this a bit more?

we lost parallelism with this.

Indeed, I removed it within the integration tests since it no longer seemed necessary. Before, the combined integration tests were taking 5+ mins, now they only take 1m 20s

https://buildkite.com/pinterest/gestalt/builds/4241
https://buildkite.com/pinterest/gestalt/builds/4510

@chrislloyd
Copy link
Contributor

@christianvuerings https://facebook.github.io/jest/docs/en/configuration.html#testenvironment-string

1:20 is still too long! As we add more we'll still have to parallelize the tests - it would be great if we could get that parallelism for free also with regular Jest unit tests.

@@ -0,0 +1,11 @@
{
"globals": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@christianvuerings i think this can be avoided, its baked into eslint now, you just need to add .integration.js to the overrides for jest env

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch - I'll do this in a follow up PR. I'd like to get this merged ASAP.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chrislloyd @christianvuerings check out #193 which updates based on the instructions here

@chrislloyd chrislloyd merged commit 05dee59 into pinterest:master May 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants