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

Support & test import() for non-bundled code #1615

Merged
merged 2 commits into from
Feb 25, 2017

Conversation

Timer
Copy link
Contributor

@Timer Timer commented Feb 22, 2017

No description provided.

@Timer
Copy link
Contributor Author

Timer commented Feb 23, 2017

Well... this is weird. "Test basic import syntax" passed ... it should've failed. 🤔
Does Jest support import() or is something else in our tool chain handle this?

edit: ignore this, it does fail but not on CI -- why? see below.

@Timer
Copy link
Contributor Author

Timer commented Feb 23, 2017

Now I'm just really confused .. fails locally but not on CI? 🌀

@Timer Timer force-pushed the defer-require branch 4 times, most recently from 9c57a84 to 2ac84ea Compare February 23, 2017 06:05
@gaearon
Copy link
Contributor

gaearon commented Feb 23, 2017

Maybe we could try running Jest with --no-cache on CI just in case.

@Timer
Copy link
Contributor Author

Timer commented Feb 23, 2017

@gaearon
Copy link
Contributor

gaearon commented Feb 23, 2017

I want to see a failing CI test 😢

@Timer
Copy link
Contributor Author

Timer commented Feb 23, 2017

I wonder if our CI tests even work ...
I'm going to try to look more into this.

@Timer
Copy link
Contributor Author

Timer commented Feb 23, 2017

/cc @EnoahNetzach

@EnoahNetzach
Copy link
Contributor

EnoahNetzach commented Feb 24, 2017

Back when I was working on CI tests, I tried to make it fail (e.g. with #1160), and my tests always failed correctly..

Also, running this branch in a docker container EnoahNetzach:create-react-app/local-testing won't fail.

Did you link babel-preset-react-app? I just tested it and without the link it was failing.


describe('promises', () => {
it('renders without crashing', () => {
const div = document.createElement('div');
return new Promise(resolve => {
ReactDOM.render(<Promises onReady={resolve} />, div);
return import('./Promises').then(({ default: Promises }) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

wouldn't it be better to give import its own test case?

@Timer Timer force-pushed the defer-require branch 2 times, most recently from 747263e to 40ac3c6 Compare February 25, 2017 00:51
@Timer
Copy link
Contributor Author

Timer commented Feb 25, 2017

@gaearon I think the tests are just flaky (for an unknown reason).
Notice the fail and pass when I revert and then revert the revert.

Should I create a new PR?

@gaearon
Copy link
Contributor

gaearon commented Feb 25, 2017

Flaky as in "sometimes fails when it shouldn't" is understandable and fine.
Flaky as in "sometimes passes when it shouldn't" is weird and we need to figure out why.

@Timer
Copy link
Contributor Author

Timer commented Feb 25, 2017

Okay, so it passes when the other commit it present. a373aec fails when c2ab8fb is missing, but a373aec starts passing when c2ab8fb is present.

So I'm not sure if this is a travis bug or a e2e bug (or just how travis works). If it was a e2e bug that means we're somehow grabbing the latest. A travis bug would mean they're grabbing the latest PR and not that specific commit.

@Timer
Copy link
Contributor Author

Timer commented Feb 25, 2017

Looks like travis does git fetch origin +refs/pull/1615/merge: and git checkout -qf FETCH_HEAD which means Travis is only capable of testing the latest given commit in a PR, not older commits.

tl;dr this should be safe to land

@gaearon
Copy link
Contributor

gaearon commented Feb 25, 2017

Do you mean that it might display a previous commit has passed while in reality it has grabbed the most recent pushed commit (that hasn't reached the queue yet)?

@Timer
Copy link
Contributor Author

Timer commented Feb 25, 2017

That's exactly what it does. But only for PRs.
Our master branch checks out the commit like it should, e.g. git checkout -qf 3289c3202149980b0ce4326e39d5501ee88d5284 (so no need to worry there).

Basically if you push a broken commit A, and then push a working commit B before the travis job starts for commit A, commit A will pass because it grabs commit B.

@gaearon
Copy link
Contributor

gaearon commented Feb 25, 2017

OK, that makes sense.
So what happened is:

  • You push commit A
  • Travis enqueues a job
  • You push commit B
  • Travis enqueues another job
  • Travis executes the first job, effectively fetching commit B, but GH integration shows the checkmark for A because that’s what the job was queued for
  • Travis executes the second job

@Timer
Copy link
Contributor Author

Timer commented Feb 25, 2017

That would be it. 😄

edit for people for people looking from twitter: this only affects pull requests, not branches

@gaearon
Copy link
Contributor

gaearon commented Feb 25, 2017

OK today I learned. 😅

@Timer
Copy link
Contributor Author

Timer commented Feb 25, 2017

I noticed this when I pushed the second commit shortly after the first, because Node 4 kitchensink had started (and failed) and then the Node 6 kitchensink (queued not executing when I pushed second commit) succeeded. I then re-validated my theory by only running the first commit alone then pushing the second commit and re-running the first job, seeing it magically switch from failing to passing.

Think this is worthwhile enough to report to travis? Prob the intended functionality... Confusing never the less.

@gaearon
Copy link
Contributor

gaearon commented Feb 25, 2017

Meh, I guess this is as designed.

@gaearon
Copy link
Contributor

gaearon commented Feb 25, 2017

Good job figuring it out tho

@Timer
Copy link
Contributor Author

Timer commented Feb 25, 2017

Thanks! Good to land?

@gaearon
Copy link
Contributor

gaearon commented Feb 25, 2017

Yep

@Timer Timer merged commit 2288ddf into facebook:master Feb 25, 2017
@Timer Timer deleted the defer-require branch February 25, 2017 05:03
@mhart
Copy link

mhart commented Feb 25, 2017

Just to clarify, because the wording of "effectively fetching commit B" confused me a bit:

This is because Travis wants to use the post-merge commit – ie, when a push on a PR happens and GitHub checks if it is "ok to merge", GitHub actually performs the merge itself between the current state of the PR branch and the branch it's been opened on (eg, master).

The resulting commit (which is only available remotely, as something like +refs/pull/1615/merge – a moving target) is the one that Travis is trying to use because it's a more comprehensive check of how things will probably look if the PR is merged. It could of course just use the commit that was pushed, which wouldn't have race conditions, but that commit could be out of date w/ respect to the branch the PR has been opened on (ie, master could have a whole bunch more commits on it since the PR was opened), so wouldn't be as safe a representation of how things will look post-merge.

If GitHub offered a reference like refs/pull/1615/merge-<commit-sha> then this wouldn't be an issue (but it would also require an order of magnitude more references on GH's end).

@Timer Timer mentioned this pull request Feb 27, 2017
5 tasks
kst404 pushed a commit to kst404/e8e-react-scripts that referenced this pull request Mar 2, 2017
* Test basic import syntax

* Compile import() in test, only support syntax otherwise
@lock lock bot locked and limited conversation to collaborators Jan 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants