Last active
May 26, 2017 17:38
-
-
Save josephhanson/084bbb635bac08c111d7ef9a8c704d32 to your computer and use it in GitHub Desktop.
Prepare for Angular 1 Testing Using Karma/Jasmine/PhantomJS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Download and install NodeJs | |
Open a command/terminal and type npm to verify installation and path variable setup | |
Run npm install -g karma | |
Run npm install -g karma-cli | |
Run npm install karma-jasmine karma-phantom-launcher jasmine-core --save-dev | |
Add minimal karma.conf file to project root directory | |
//jshint strict: false | |
module.exports = function(config) { | |
config.set({ | |
basePath: './app', // path relative to .conf.js file where all other files can be found | |
files: [ | |
'src/**/*.js', | |
'tests/**/*.spec.js' | |
], | |
autoWatch: true, | |
frameworks: ['jasmine'], | |
browsers: ['PhantomJS'], | |
plugins: [ | |
'karma-phantomjs-launcher', | |
'karma-jasmine' | |
] | |
}); | |
}; | |
Add the following file verify.spec.js to the tests directory | |
describe("verify jasmine/karma setup", function() { | |
it ('should verify karma/jasmine is working', function() { | |
expect(1).toEqual(1); | |
}); | |
}); | |
Run karma start in the directory with the karma.conf.js file | |
If everything is setup correctly you should see Executed 1 of 1 SUCCESS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment