????????????????
????????????????????????????????????karma-coverage??????karma???????????????????????????????????????????
????npm install karma-coverage -save
??????karma.conf.js????м?????
// ???????????????????????
coverageReporter: {
type: 'html'??
dir: 'coverage'
}??
// ?????????????????????????????????????controller?????
preprocessors: {'js/*.js': ['coverage']}
// ???????'karma-coverage'
plugins: [
'karma-chrome-launcher'??
'karma-jasmine'??
'karma-junit-reporter'??
'karma-coverage'??
]??
// ??????? coverage
reporters: ['progress'?? 'coverage']??
???????е?????????????????coverage????У????index.html???????????????

????E2E????
????e2e?????????end-to-end??????UI?????????????????????????????????????β????????????????????????????????????????????????????????????????????????????UI??????????
????????E2E????
????????????e2e-test???protractor.conf.js?????????????protractor?????????????
exports.config = {
allScriptsTimeout: 11000??
baseUrl: 'http://localhost:8000/app/'??
// Capabilities to be passed to the webdriver instance.
capabilities: {
'browserName': 'chrome'
}??
framework: 'jasmine'??
// Spec patterns are relative to the configuration file location passed
// to protractor (in this example conf.js).
// They may include glob patterns.
specs: ['*.js']??
// Options to be passed to Jasmine-node.
jasmineNodeOpts: {
showColors: true?? // Use colors in the command line report.
}??
defaultTimeoutInterval: 30000
};
????????package.json scripts??????
????"preupdate-webdriver": "npm install"??
????"update-webdriver": "webdriver-manager update"??
????"preprotractor": "npm run update-webdriver"??
????"protractor": "protractor e2e-test/protractor.conf.js"
??????дe2e??????
?????????????????????a??????1???????b???2?????????3
describe('index.html'?? function() {
beforeEach(function() {
browser.get('http://localhost:8000/html');
});
it('get index html'?? function() {
var a = element(by.model('a'));
var b = element(by.model('b'));
a.sendKeys(1);
b.sendKeys(2);
var result = element(by.id('result'));
expect(result.getText()).toEqual('3');
});
});
??????в??????????
????????????????????????webdriver(????webdriver http://sentsin.com/web/658.html)??
??????????protractor?????
????npm i -g protractor
?????:????????webdriver???FQ??????webstrom?????????????
??????webstrom???л???Terminal???????Terminal??????????·?????????:
????set PROXY=http://localhost:1080
????set HTTP_PROXY=%PROXY%
????set HTTPS_PROXY=%PROXY%
???????????ó????????????????
????npm run update-webdriver
???????e2e?????????????????????????????????????????????????e2e???????????????selenium?????
????npm run protractor
????