Skip to content

Test script shorthands

tpronk edited this page Dec 7, 2022 · 10 revisions

Home - Test script shorthands


Shorthands for automated testing

The command below compiles the PsychoJS library, deploy test experiments (insofar required), and run the tests, all in one go. It can be configured via Testrun CLI options, the deployExperiments CLI options, and these CLI options:

  • --compile Also compile the test-experiments before deploying them
  • --nocss Don't build the CSS parts of the PsychoJS library
  • --nojs Don't build the JS of the PsychoJS library
  • --notests Don't run any tests
  • --beep Play a beep when the command has finished

node test.cjs

Steps executed

  1. Build the PsychoJS library: npm run build:css && npm run build:js
  2. Perform any Karma tests that match the label CLI option.
  3. Deploy test experiments for any WebdriverIO tests that match the label CLI option.
  4. Perform any WebdriverIO tests that match the label CLI option.

Examples

Example 1

Run a test with the following settings:

  • Compile the PsychoJS library
  • Deploy the test-experiments that match the label "wdio_img" to the stager
  • Use the local Selenium sever
  • Use the local web-server

node test.cjs --server local --url local --label wdio_img

This use case also has a "super-shorthand command":

npm start karma_formattedString

Example 2

Note this test requires features only available to the PsychoPy/PsychoJS team

Run a test with the following settings:

  • Compile the PsychoJS library
  • Deploy the test-experiments that match the label "full" to the stager
  • Use BrowserStack as Selenium/Appium server
  • Use the stager as web-server (with experiments hosted at the URL https://staging.psychopy.org/experiments/<branch>/{{experiment}})
  • Run tests that match the label "full"
  • Use thomas as name for the branch
  • Use my_testrun as name for the testrun
  • Run the tests on each platform that is part of the platform subset
  • Upload the testlogs to the PsychoPy staging server, where they will be available at https://staging.psychopy.org/report_wdio/thomas/my_testrun/ and https://staging.psychopy.org/report_karma/thomas/my_testrun/

node test.cjs --platform * --subset --server bs --branch thomas --testrun my_testrun --url stager --uploadExperiments --uploadResults --label full

Shorthands for automated building

The shorthands below automatically build and deploy a test-experiment when something changes to PsychoPy, PsychoJS, or the test-experiment itself.

On a change in PsychoPy, PsychoJS, or the test-experiment, rebuild the library, compile the test-experiment, and deploy it

The command below watches the directories below for changes. If a change occurs, it builds both the JS and CSS part of PsychoJS, and compiles and deployes the experiment with label wdio_img. Note that this command is comprehensive, but also relatively slow. The other commands in this section are faster, because they only watch for specific parts of PsychoPy, PsychoJS, and a test-experiment, and then only perform the building steps required for reflecting that change.

  • src/ directory in the PsychoJS repo
  • psychopy/ directory in the PsychoPy repo
  • tests/ directory in the psychojs_testing repo

npm run watch_all wdio_img

On a change in PsychoJS, build its JS part, and deploy a test-experiment

The command below watches the src/ directory in the PsychoJS repo for any changes. If a change occurs, it builds the JS part of PsychoJS, deploys the experiment with label wdio_img, and plays two beeps when done.

npm run watch_psychojs_js wdio_img

On a change in PsychoJS, build its CSS part, and deploy a test-experiment

The command below watches the src/ directory in the PsychoJS repo for any changes. If a change occurs, it builds the CSS part of PsychoJS, deploys the experiment with label wdio_img, and plays two beeps when done.

npm run watch_psychojs_css wdio_img

On a change in a test-experiment, compile and deploy it with the PsychoJS library

The command below watches the tests/ directory in the psychojs_testing repo for any changes. If a change occurs, it compiles and deploys the experiment with label wdio_img, and plays two beeps when done.

npm run watch_experiment wdio_img

On a change in PsychoPy, compile and deploy a test-experiment

The command below watches the psychopy/ directory in the PsychoPy repo for any changes. If a change occurs, it compiles and deploys the experiment with label wdio_img, and plays two beeps when done.

npm run watch_psychopy wdio_img

Clone this wiki locally