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

Add Jest, Playwright and pytest tests #207

Merged
merged 56 commits into from
Jun 4, 2022

Conversation

fcollonval
Copy link
Member

Fixes #137

@fcollonval fcollonval changed the title Add Jest and Playwright tests Add Jest, Playwright and pytest tests Feb 12, 2022
"@jupyterlab/builder": "^3.1.0",
"@jupyterlab/galata": "^4.1.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

i dunno man... while webpack+babel and friends are heavy, the galata/playwright stack is huge, and i've seen a lot of experienced folk struggle with getting to Works On My Machine with it. If this is going in-by-default, I feel like the pattern of putting the heavyweight browser tests in a separate ./ui-tests/package.json and yarn.lock which can be fired off from the main package.json makes more sense.

From a CI value perspective: i've found it pays good dividends for heavyweight ui tests to be in an entirely separate, dependent, os-matrixed job where the "as-would-be-released" .whl and .tar.gz assets are installed and tested against. This allows the ui tests to fail really fast if something isn't packaged properly, which is usually much worse than being off by a few pixels in screenshot comparisons.

opens the server to the world and provide access to JupyterLab
JavaScript objects through the global window variable.
"""
from tempfile import mkdtemp
Copy link
Contributor

Choose a reason for hiding this comment

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

real estate in the root folder is precious: recommend putting this in the tests folder

c.ServerApp.port_retries = 0
c.ServerApp.open_browser = False

c.ServerApp.root_dir = mkdtemp(prefix='galata-test-')
Copy link
Contributor

Choose a reason for hiding this comment

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

this won't clean up after itself

Copy link
Member Author

Choose a reason for hiding this comment

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

The setup is done like that to mimic pytest system (without the auto clean-up feat though).

The UI tests can easily fail if the filebrowser is crowded by existing files (due to past test runs or previous tests). To mitigate that problem, galata is creating a folder for each test (using the test name). That folder and its content will be deleted in the teardown step. So the temporary folder is likely to end up empty at the end of a test run; except if an error occurs. If an error occurs, the files are not removed (default behavior). So they can be access afterwards for introspection. That behavior is controlled by a fixture.

So I don't see any problem crowding the temporary folder as per definition it is the first place to clean if you end up having low disk space. And this is much easier than going through tens of projects folder for removing test artifacts.

@@ -0,0 +1,8 @@
import pytest

pytest_plugins = ["jupyter_server.pytest_plugin"]
Copy link
Contributor

Choose a reason for hiding this comment

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

i thought the newer pytest started warning about doing this in a config (e.g. pyproject.toml, setup.cfg, tox.ini or pytest.ini)

Copy link
Member Author

Choose a reason for hiding this comment

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

This is the way documented in the official documentation

@fcollonval
Copy link
Member Author

GitHub workflow generated using commit 2bb2088 has been tested successfully there

integration-tests:
name: Integration tests
needs: build
runs-on: ubuntu-latest
Copy link
Contributor

Choose a reason for hiding this comment

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

while ubuntu is a nice, predictable, well-behaved platform, windows is frankly where, from an overall integration testing perspective, one is most likely to get real data and catch evil things.

other fun things to find extremely predictable bugs:

  • installing/running/serving from paths with non-ascii characters and spaces
  • non-c:-drive installs
  • running with a non-/ base url

@3coins
Copy link
Contributor

3coins commented May 28, 2022

@fcollonval
I checked out your changes, and tested locally. Everything works, there are some minor points that we can tackle in a separate PR.
I also attempted a rebase from 3.0 branch and saw some conflicts, resolved them and tried submitted a PR to help you with the merge and CI failures, but it seems like GitHub is not showing the correct diff in the PR. Here is my branch.
https://github.com/3coins/extension-cookiecutter-ts/tree/3coins-add-testing

You should be able to merge your changes after a rebase from 3.0 branch. Thanks for working on this PR!

@fcollonval
Copy link
Member Author

Thanks @3coins CI is now green.

@jtpio
Copy link
Member

jtpio commented Jun 1, 2022

Thanks!

cc @3coins if you want to have a final look

@3coins
Copy link
Contributor

3coins commented Jun 1, 2022

@jtpio
I will checkout and test again shortly.

{{cookiecutter.python_name}}/README.md Show resolved Hide resolved
{{cookiecutter.python_name}}/ui-tests/README.md Outdated Show resolved Hide resolved
@fcollonval
Copy link
Member Author

@3coins I applied your suggestion and add the feature under a flag as requested during the JupyterLab meeting. Is the latest version good for you?

@3coins
Copy link
Contributor

3coins commented Jun 3, 2022

@fcollonval
Thanks a lot working on those updates. LGTM!

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.

Add testing
4 participants