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

test: fix e2e tests to cleanup properly #4847

Closed
wants to merge 5 commits into from

Conversation

malcolm-kee
Copy link
Contributor

Cleanup browser/server properly when assertion fails.

  • This is a bugfix
  • This is a feature
  • This is a code refactor
  • This is a test update
  • This is a docs update
  • This is a metadata update

For Bugs and Features; did you add new tests?

Motivation / Use-Case

Breaking Changes

Additional Info

resolves #4846

@alexander-akait
Copy link
Member

So the problem in puppeteer itself? Because if we put just throw new Error("test"); our tests failed succefully (I think I am right here 😄 )

@codecov
Copy link

codecov bot commented May 6, 2023

Codecov Report

Patch and project coverage have no change.

Comparison is base (99f66cb) 91.96% compared to head (f0adeb0) 91.96%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4847   +/-   ##
=======================================
  Coverage   91.96%   91.96%           
=======================================
  Files          16       16           
  Lines        1704     1704           
  Branches      647      647           
=======================================
  Hits         1567     1567           
  Misses        126      126           
  Partials       11       11           

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@malcolm-kee
Copy link
Contributor Author

malcolm-kee commented May 6, 2023

@alexander-akait sorry what do you mean? "Failed successfully" need some translation 😆

@alexander-akait
Copy link
Member

Failed successfully" need some translation laughing

It means if we will put throw new Error("test"): in our tests (inside it(...)), our tests will be failed, and it is succefully (and expected), because it should happen when we do it 😄

@alexander-akait
Copy link
Member

But I see intresting error:

TypeError: Converting circular structure to JSON
        --> starting at object with constructor 'BrowserContext'
        |     property '_browser' -> object with constructor 'Browser'
        --- property '_defaultContext' closes the circle
        at stringify (<anonymous>)

maybe we forgot to cleanup something between runs?

@malcolm-kee
Copy link
Contributor Author

Failed successfully" need some translation laughing

It means if we will put throw new Error("test"): in our tests (inside it(...)), our tests will be failed, and it is succefully (and expected), because it should happen when we do it 😄

It's not reliable behavior. At least in my machine (M1 Mac) it stucks when that happen, so I think it's better to cleanup properly.

@malcolm-kee
Copy link
Contributor Author

@alexander-akait
Copy link
Member

It's not reliable behavior. At least in my machine (M1 Mac) it stucks when that happen, so I think it's better to cleanup properly.

I mean if you put throw Error("test") in it, will your tests freeze too or is it failed immediately?

@malcolm-kee
Copy link
Contributor Author

@alexander-akait it will stuck because of dev server.

Minimal test case:

const server = new Server({ port }, webpack(config));

await server.start();

throw new Error("What");

await server.stop();

@malcolm-kee malcolm-kee force-pushed the test/refactor-test branch from 123ba75 to a619788 Compare May 7, 2023 04:00
@malcolm-kee malcolm-kee marked this pull request as ready for review May 7, 2023 04:03
@alexander-akait
Copy link
Member

@malcolm-kee Did you look why it happens? I am fine with test refactor, just want to check it out, maybe we don't close/cleanup something

@malcolm-kee malcolm-kee force-pushed the test/refactor-test branch from a619788 to 9e25c80 Compare May 7, 2023 13:51
@malcolm-kee
Copy link
Contributor Author

@alexander-akait I think it's expected (unless this deviates what you understand).

From my experience and also the docs I refer, in general testing NodeJS server with jest do not call the server's listen method because it will start a long-running process. However, .listen is called in Server.start().

@malcolm-kee malcolm-kee force-pushed the test/refactor-test branch from 9e25c80 to a2edf1d Compare May 7, 2023 14:30
@malcolm-kee malcolm-kee force-pushed the test/refactor-test branch from a2edf1d to f0adeb0 Compare May 7, 2023 14:43
Copy link
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

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

/cc @snitin315 Will it create problems with the next branch rebase, because if no I will merge, if yes, we can emrge it in the next branch

@snitin315
Copy link
Member

@alexander-akait Yes, let's merge directly in the next branch. @malcolm-kee Can you rebase the PR on top of the next branch?

@alexander-akait alexander-akait changed the base branch from master to next May 9, 2023 05:11
@alexander-akait
Copy link
Member

@malcolm-kee We remove some things from the next version, so tests doesn't exists, like webpack v4, some API and etc, hope rebasing will be easy, anyway feel free to ask any question

@malcolm-kee
Copy link
Contributor Author

Hmm too much conflict, I'll close this PR and redo it based on next.

@malcolm-kee
Copy link
Contributor Author

Replace with #4859

snitin315 added a commit that referenced this pull request Jun 22, 2023
<!--
  Thank you for submitting a pull request!

  Please note that this template is not optional and all _ALL_ fields must be filled out, or your pull request may be rejected.

  Please do not delete this template.
  Please do remove this header to acknowledge this message.

  Please place an x, no spaces, in all [ ] that apply
-->

- [ ] This is a **bugfix**
- [ ] This is a **feature**
- [ ] This is a **code refactor**
- [x] This is a **test update**
- [ ] This is a **docs update**
- [ ] This is a **metadata update**

### For Bugs and Features; did you add new tests?
No
<!-- Please note that we won't approve your changes if you don't add tests. -->

### Motivation / Use-Case
As per #4847
<!--
  What existing problem does the pull request solve?

  Please explain the motivation or use-case for making this change.
  If this Pull Request addresses an issue, please link to the issue.
-->

### Breaking Changes
No
<!--
  If this PR introduces a breaking change, please describe the impact and a
  potential migration path for existing applications.
-->

### Additional Info
No
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

Successfully merging this pull request may close these issues.

Refactor tests
3 participants