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:
- Install NodeJS
- In the root directory for your app, run npm init
- 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
- It’s important to include the /node_modules in the gitignore file so that these dependencies are not tracked by GitHub.
- It is also important to note that the “production” version of your mini app should not include any of the testing files and dependencies
- Be sure you have the latest version of the given browsers or else Selenium will throw errors.
- Write your Cucumber features in /features/my_feature.feature
- Write your step definitions in /features/support/steps.js
- Follow the selenium tutorial: Selenium WebDriver JS API
- 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 .
- 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
- Valuable References
- Cucumber-js: https://github.com/cucumber/cucumber-js
- Selenium WebDriver: https://www.npmjs.com/package/selenium-webdriver , https://www.selenium.dev/selenium/docs/api/javascript/index.html
- Chai: https://github.com/chaijs/chai
- Our GitHub (referencing our file structures and code will likely be the most helpful): https://github.com/cwrothrock/Animations-in-Stress-Learning-Content