-
Notifications
You must be signed in to change notification settings - Fork 19
Testing
To run tests, go into the central project directory and run:
yarn test
This command will determine your machine's OS and run all possible tests. When in development, individuals can run front end tests with yarn test-ui
and backend tests with yarn test-backend
.
Required Extra Steps: Due to quirks in the libraries we're using, there are few things to do in order for all tests to pass:
- Run
yarn start
in another terminal before runningyarn test
. Some ui-tests will fail because it takes longer for the site instance to spin up than it takes for the tests to start. - Ensure that all browsers' testing windows are open while the tests are running. TestCafe has been known to have some issues if those windows are minimized, possibly causing some tests to fail when they shouldn't.
- Zoom out ridiculously far out on the ui-test's browser windows once they open. There are currently some issues we have with the our fixed copy-button that cause some tests to fail if the
Other Known Issues:
-
Using Git Bash on Windows? It may look like the test aren't running on your machine. Hit enter a second time after running your yarn test command. The specifics of why this happens are still unknown, but this should help when running your tests.
-
Getting a
node\r: No such file or directory
error when running tests on Mac? You may need to change a file in one of the dependencies to Unix line endings. From the top-levelflux
directory, navigate tonode_modules/run-script-os
. Open theindex.js
file invim
usingvim index.js
. From there, enter the command:set ff=unix
. Exit and save your changes (using:wq!
). Then, navigate back to the parent directory and run the tests again. It should (hopefully) work.
For docs on our testing libraries, see the Technologies Used section of our wiki.
Make sure unit testing is done with browser console open and resolve any warnings/errors that appear. In order for your code to be tested properly, and before it can be accepted in a pull request, the following must be done:
- Define backend tests for any functions your code defines or relies on. Back-end tests are found in
projectDirectory/test/backend
, are titled with the pattern<fileToTest>.test.js
, and are organized in directories identically to the source files. That is, if you're testing a function found inprojectDirectory/src/patient/Patient.jsx
, you will define your test in a file found atprojectDirectory/test/backend/patient/Patient.test.js
. If there is no file or no corresponding folder, you should make one. - Define front-end tests for any new ui-components you define, as well as any components you rely on in your new feature. Front-end tests are found in
projectDirectory/test/ui
and are titled with the pattern<viewToTest>.js
. That is, if you're testing a ui-component displayed when using the viewprojectDirectory/src/view/SlimApp.jsx
, you will define your test in a file found atprojectDirectory/test/ui/SlimApp.js
. If there is no file, you need to make one.-
Do not add
.test
to the filename. This will make the backend test script try to run this file, which will fail and make it look like your tests don't work
-
Do not add
To run just a single UI test when you run UI tests, add ".only" after the test keyword to begin the test. For example:
test.only('Clicking event buttons selects corresponding event', async t => {
const clinicalEventSelector = Selector('.clinical-event-select');
// Post-encounter is pre-selected
await t
.expect(await clinicalEventSelector.textContent)
.eql('Post-encounter');
...
By doing this, when you run the ui tests, just this test will run.
To run just the ui tests you can run “yarn test-ui”.
https://devexpress.github.io/testcafe/documentation/test-api/test-code-structure.html#skipping-tests
Copyright © 2017 The MITRE Corporation | Approved for Public Release; Distribution Unlimited. Case Number 16‑1988
- Home
- About Flux Notes
- Active Treatment Summary Objects
- Data Standards for Breast Cancer
- Database decision
- Declarative Shortcut Format
- Demo Script
- Deployment Plan - Lite Mode
- Dragon Software Information and Troubleshooting
- Flux Notes Lite Demo Script
- How To Create New Shortcuts
- Interaction Between REACT.js Components in Flux
- JavaScript and HTML Code Style Guide
- Key Application Features
- Minimap Evaluation
- Naming Convention for Visual Components
- NLP Server: Provisioning and Troubleshooting
- Pre Release Testing Script
- Profiling and Performance
- Redux Implementation Guide
- Shorthand Context Problem
- Testing
- Third Party Libraries Changes
- Demo Scenarios -- (out of date)