forked from jupyterlab/extension-cookiecutter-ts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
10 changed files
with
260 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
name: Tests validation | ||
|
||
on: | ||
push: | ||
branches: ["*.0"] | ||
pull_request: | ||
branches: "*" | ||
schedule: | ||
- cron: "0 0 * * *" | ||
|
||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Base Setup | ||
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 | ||
|
||
- name: Install dependencies | ||
run: python -m pip install -U cookiecutter check-manifest jupyterlab~=3.1 | ||
|
||
- name: Create the extension | ||
run: | | ||
set -eux | ||
# Trick to use custom parameters | ||
python -m cookiecutter --no-input . | ||
- name: Test the extension | ||
run: | | ||
set -eux | ||
jlpm | ||
jlpm test | ||
- name: Install the extension | ||
working-directory: myextension | ||
run: | | ||
set -eux | ||
python -m pip install . | ||
- name: Launch JupyterLab | ||
working-directory: myextension | ||
run: | | ||
jupyter lab --config jupyter_server_test_config.py 2>&1 > /tmp/jupyterlab_server.log & | ||
- name: Install browser | ||
working-directory: myextension | ||
run: | | ||
jlpm playwright install chromium | ||
- name: Wait for JupyterLab | ||
uses: ifaxity/wait-on-action@v1 | ||
with: | ||
resource: http-get://localhost:8888/lab | ||
timeout: 360000 | ||
|
||
- name: Execute integration tests | ||
working-directory: myextension | ||
run: | | ||
jlpm run playwright test ./ui-tests | ||
- name: Upload Playwright Test assets | ||
if: always() | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: myextension-playwright-test-assets | ||
path: | | ||
myextension/test-results | ||
- name: Upload Playwright Test report | ||
if: always() | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: myextension-playwright-report | ||
path: | | ||
myextension/playwright-report |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
{{cookiecutter.python_name}}/.github/workflows/integration-tests.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
name: Integration tests | ||
|
||
on: | ||
push: | ||
branches: main | ||
pull_request: | ||
branches: '*' | ||
|
||
jobs: | ||
integration-tests: | ||
name: Playwright tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Base Setup | ||
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 | ||
|
||
- name: Install dependencies | ||
run: python -m pip install -U jupyterlab~=3.1 check-manifest | ||
|
||
- name: Install the extension | ||
run: | | ||
set -eux | ||
jlpm | ||
python -m pip install . | ||
- name: Launch JupyterLab | ||
run: | | ||
jupyter lab --config jupyter_server_test_config.py 2>&1 > /tmp/jupyterlab_server.log & | ||
- name: Install browser | ||
run: | | ||
jlpm playwright install chromium | ||
- name: Wait for JupyterLab | ||
uses: ifaxity/wait-on-action@v1 | ||
with: | ||
resource: http-get://localhost:8888/lab | ||
timeout: 360000 | ||
|
||
- name: Execute integration tests | ||
run: | | ||
jlpm run playwright test ./ui-tests | ||
- name: Upload Playwright Test assets | ||
if: always() | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: {{ cookiecutter.python_name }}-playwright-test-assets | ||
path: | | ||
test-results | ||
- name: Upload Playwright Test report | ||
if: always() | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: {{ cookiecutter.python_name }}-playwright-report | ||
path: | | ||
playwright-report |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('@jupyterlab/testutils/lib/babel.config'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const jestJupyterLab = require('@jupyterlab/testutils/lib/jest-config'); | ||
|
||
const esModules = [ | ||
'@jupyterlab/', | ||
'lib0', | ||
'y\\-protocols', | ||
'y\\-websocket', | ||
'yjs' | ||
].join('|'); | ||
|
||
const jlabConfig = jestJupyterLab(__dirname); | ||
|
||
const { | ||
moduleFileExtensions, | ||
moduleNameMapper, | ||
preset, | ||
setupFilesAfterEnv, | ||
setupFiles, | ||
testPathIgnorePatterns, | ||
transform | ||
} = jlabConfig; | ||
|
||
module.exports = { | ||
moduleFileExtensions, | ||
moduleNameMapper, | ||
preset, | ||
setupFilesAfterEnv, | ||
setupFiles, | ||
testPathIgnorePatterns, | ||
transform, | ||
automock: false, | ||
collectCoverageFrom: ['src/**/*.{ts,tsx}', '!src/**/*.d.ts'], | ||
coverageDirectory: 'coverage', | ||
coverageReporters: ['lcov', 'text'], | ||
globals: { | ||
'ts-jest': { | ||
tsconfig: 'tsconfig.json' | ||
} | ||
}, | ||
testRegex: 'src/.*/.*.spec.ts[x]?$', | ||
transformIgnorePatterns: [`/node_modules/(?!${esModules}).+`] | ||
}; |
17 changes: 17 additions & 0 deletions
17
{{cookiecutter.python_name}}/jupyter_server_test_config.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
"""Server configuration for integration tests. | ||
!! Never use this configuration in production because it | ||
opens the server to the world and provide access to JupyterLab | ||
JavaScript objects through the global window variable. | ||
""" | ||
from tempfile import mkdtemp | ||
|
||
c.ServerApp.port = 8888 | ||
c.ServerApp.port_retries = 0 | ||
c.ServerApp.open_browser = False | ||
|
||
c.ServerApp.root_dir = mkdtemp(prefix='galata-test-') | ||
c.ServerApp.token = "" | ||
c.ServerApp.password = "" | ||
c.ServerApp.disable_check_xsrf = True | ||
c.LabApp.expose_app_in_browser = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/** | ||
* Configuration for Playwright using default from @jupyterlab/galata | ||
*/ | ||
module.exports = require('@jupyterlab/galata/lib/playwright-config'); |
9 changes: 9 additions & 0 deletions
9
{{cookiecutter.python_name}}/src/__tests__/{{cookiecutter.python_name}}.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** | ||
* Example of [Jest](https://jestjs.io/docs/getting-started) unit tests | ||
*/ | ||
|
||
describe('{{ cookiecutter.labextension_name }}', () => { | ||
it('should be tested', () => { | ||
expect(1 + 1).toEqual(2); | ||
}) | ||
}) |
22 changes: 22 additions & 0 deletions
22
{{cookiecutter.python_name}}/ui-tests/{{cookiecutter.python_name}}.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { test } from '@jupyterlab/galata'; | ||
import { expect } from '@playwright/test'; | ||
|
||
/** | ||
* Don't load JupyterLab webpage before running the tests. | ||
* This is required to ensure we capture all log messages. | ||
*/ | ||
test.use({ autoGoto: false }) | ||
|
||
test('should emit an activation console message', async ({ page }) => { | ||
const logs: string[] = []; | ||
|
||
page.on('console', (message) => { | ||
logs.push(message.text()); | ||
}); | ||
|
||
await page.goto(); | ||
|
||
expect( | ||
logs.filter((s) => s === 'JupyterLab extension {{ cookiecutter.labextension_name }} is activated!') | ||
).toHaveLength(1); | ||
}); |