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

Small changes to test setup/layout #257

Merged
merged 7 commits into from
Oct 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions docs/contribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ In order to get Thebe running locally, you'll need to have Node installed on you

- Install Node by [following the nodejs instructions](https://nodejs.org/en/download/)
- Install Node through `conda`

```bash
conda install -c conda-forge nodejs
```
Expand Down Expand Up @@ -77,13 +77,27 @@ to run auto-formatting prior to each commit.

# Testing Thebe

You can run the tests locally with `npm test`.
You can run the tests locally with `npm test` or `npm run test:watch`.
Alternately, you can push your changes to GitHub and let the tests run automatically via GitHub Actions.

Test code is in the `test` directory, and you can write new tests in there.
You can also test interactively by running `npm run develop` to open and serve `development.html` with the current build of thebe.
Test code is in the `test` directory, and you can write new tests in there see **Adding Tests** below.

You can also test manually interactively by running `npm run develop` to open and serve `development.html` with the current build of thebe.

TODO: get testing infrastructure to a point where we can reasonably request tests for new features.
## Adding Tests

- [karma](https://karma-runner.github.io/latest/index.html) is used for automated testing and configured in [karma.conf.js](.karma.conf.js)
- `karma` uses the same `webpack` configuration as the build from [webpack.config.js](./webpack.config.js)
- Test files are in the `test` directory and currently setup in a single entry-point fashion, with all tests being required by the `test_entrypoint.js` file. This has pros and cons:
- pro - `webpack` builds a single bundle which is faster
- pro - we have a single top level describe block that we know will execute first, so can use before/after to start and shutdown a Jupyter server
- con - we cannot run single tests, only the full bundle

TODO: create some exemplar tests that:
- [ ] test starting thebe with different options and controlling on page state at bootstrap
- [ ] test the initial thebe render
- [ ] test interacting with the server and rendering results

# Releasing Thebe

Expand Down
11 changes: 11 additions & 0 deletions jupyter-server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { JupyterServer } from "@jupyterlab/testutils";
const server = new JupyterServer();

server
.start()
.then((msg) => {
console.log("Started Jupyter Server", msg);
})
.catch((msg) => {
console.log("Server start failed", msg);
});
7 changes: 3 additions & 4 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
module.exports = function (config) {
config.set({
files: ["test/**/*.js"],
files: ["test/test_entrypoint.js"],
frameworks: ["mocha"],

preprocessors: {
// only specify one entry point
// and require all tests in there
"test/test.js": ["webpack"],
"test/test_entrypoint.js": ["webpack"],
},
reporters: ["progress", "spec", "coverage-istanbul"],
reporters: ["mocha", "coverage-istanbul"],
port: 9876, // karma web server port
colors: true,
logLevel: config.LOG_DEBUG,
Expand Down
Loading