The script will install packages and create config files that are needed for Ionic 3 testing. This setup and configurations are based on https://www.joshmorony.com/introduction-to-testing-ionic-2-applications-with-testbed/
A second script was created "initIonicTest2.sh" which is based on https://github.com/driftyco/ionic-unit-testing-example
- Create a new Ionic 3 project
- Copy the script initIonicTest.sh OR initIonicTest2.sh to your project's root directory
- Add permission and run the script
$ chmod u+x initIonicTest.sh
$ ./initIonicTest.sh
- Add test script to your package.json
- If you are using initIonicTest.sh add:
"test": "ng test"
- If you are using initIonicTest2.sh add:
"test": "karma start ./test-config/karma.conf.js",
"test-ci": "karma start ./test-config/karma.conf.js --single-run",
"e2e": "webdriver-manager update --standalone false --gecko false; protractor ./test-config/protractor.conf.js"
- Run the test
$ npm test
- initIonicTest.sh - ERROR in Could not resolve module @angular/router - Current issue with @angular/cli. Just modify a file (eg. tsconfig.test.json) and it will resume.