local testing of js apps - dsandeep97/BiologyAnimation GitHub Wiki

Since it is purely low-level HTML, CSS, and JavaScript-based apps, we used development-dependent node modules. If you’d like to set up your own automated testing environment like ours, you can follow the simple steps:

  1. Install NodeJS
  2. In the root directory for your app, run npm init
  3. Install the necessary development modules: npm install --save-dev cucumber selenium-webdriver chai Depending on the browsers you want to test with, you can install the following modules: Google Chrome: chromedriver Microsoft Edge: edgedriver Firefox: geckodriver Internet Explorer: iedriver
  4. It’s important to include the /node_modules in the gitignore file so that these dependencies are not tracked by GitHub.
  5. It is also important to note that the “production” version of your mini app should not include any of the testing files and dependencies
  6. Be sure you have the latest version of the given browsers or else Selenium will throw errors.
  7. Write your Cucumber features in /features/my_feature.feature
  8. Write your step definitions in /features/support/steps.js
  9. Follow the selenium tutorial: Selenium WebDriver JS API
  10. Remember to use async and await in your step definitions/world functions so that your code can finish execution during steps/document manipulation. Here is more documentation for JavaScript Promises and Async/Await .
  11. In package.json , you can write a test script to run with npm : “scripts”: { “test”: “./node_modules/.bin/cucumber-js” } Then, on your command line at root directory: npm run test
  12. Valuable References
  13. Cucumber-js: https://github.com/cucumber/cucumber-js
  14. Selenium WebDriver: https://www.npmjs.com/package/selenium-webdriver , https://www.selenium.dev/selenium/docs/api/javascript/index.html
  15. Chai: https://github.com/chaijs/chai
  16. Our GitHub (referencing our file structures and code will likely be the most helpful): https://github.com/cwrothrock/Animations-in-Stress-Learning-Content