This repository contains the source code for the cloudflare worker of Serlo.
yarn test
– run all testsyarn lint
– run linter against the codebaseyarn check:all
– run all checks (tests and lints)
You can run tests with yarn test
. We use jest and thus all jest command line options can be used.
It is also possible to run tests against other environments (the default environment is testing against the local source code):
yarn test:staging
– Test againstserlo-staging.dev
yarn test:production
– Test againstserlo.org
At __test__/__utils__
there are utility functions for writing tests:
fetch-helper.ts
:fetchSerlo()
- does an request at the current testing environment. For example whenTEST_ENVIRONMENT=staging
it makes a request at*.serlo-staging.dev
. Use this function whenever possible. By setting{ environment: TestEnvironment.Locally }
you can always test against the local environment.
epxect-helper.ts
: Various assertation helper you can use.
You can use git hooks to automatically check your codebase before you push. In order to archieve this run the following commands in the root directory:
echo 'yarn check:all --no-uncommitted-changes' > .git/hooks/pre-push
chmod +x .git/hooks/pre-push
You can use the flag --no-verify
like in git push --no-verify
to bypass the checks while pushing.
In order to show a preview of components you need run yarn dev
and open http://127.0.0.1:8787/___cloudflare_worker_dev
. When you want to add your own components for a preview you can add them at ./src/cloudflare-worker-dev.tsx
.
Via embed.serlo.org/thumbnail?url=${videoUrl|appletUrl}
you can request thumbnail images for supported providers (YouTube, Vimeo, Wikimedia Commons and Geogebra).