Runing karma tests in Phantom works fine but in Chrome not. All I change in karma.config is browsers: ['PhantomJS'], to browsers: ['Chrome'],.
If I change it I have 0 tests executed and Test failed.
Here is my Chrome response:
Response with Phantom:
Here is my karma.config.js
// Karma configuration
// Generated on Mon Jan 16 2017 13:32:24 GMT+0100 (Środkowoeuropejski czas stand.)
var webpackConfig = require('./webpack.config.js');
var webpack = require('webpack');
var path = require('path');
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['mocha', 'chai', 'sinon', 'fixture'],
files: [
'spec/**/*.spec.ts',
'spec/fixtures/**/*.html',
],
exclude: [],
webpack: {
module: webpackConfig.module,
resolve: webpackConfig.resolve,
plugins: [
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
"window.jQuery": "jquery",
Tether: 'tether',
"window.Tether": 'tether'
})
],
},
preprocessors: {
"spec/**/*.ts": ['webpack'],
'spec/**/*.html': ['html2js'],
'spec/**/*.json': ['json_fixtures']
},
reporters: ['progress'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: false,
// browsers: ['Chrome'],
browsers: ['PhantomJS'],
singleRun: true,
concurrency: Infinity
})
};
And package:
"devDependencies": {
"#types/chai": "^3.4.34",
"#types/jquery": "^2.0.34",
"#types/karma-fixture": "^0.2.2",
"#types/mocha": "^2.2.37",
"#types/raty": "^2.7.26",
"#types/sinon": "^1.16.34",
"chai": "^3.5.0",
"css-loader": "^0.26.1",
"extract-text-webpack-plugin": "^2.0.0-beta.4",
"file-loader": "^0.9.0",
"karma": "^1.4.0",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^2.0.0",
"karma-fixture": "^0.2.6",
"karma-html2js-preprocessor": "^1.1.0",
"karma-json-fixtures-preprocessor": "0.0.6",
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.1",
"karma-phantomjs-launcher": "^1.0.2",
"karma-sinon": "^1.0.5",
"karma-typescript": "^2.1.6",
"karma-typescript-preprocessor2": "^1.2.1",
"karma-webpack": "^2.0.1",
"less": "^2.7.2",
"mocha": "^3.2.0",
"node-sass": "^4.0.0",
"phantomjs-prebuilt": "^2.1.14",
"sass-loader": "^4.0.2",
"sinon": "^1.17.7",
"style-loader": "^0.13.1",
"ts-loader": "^1.2.2",
"typescript": "^2.0.10",
"url-loader": "^0.5.7",
"webpack": "^2.2.0-rc.6"
}
Adding a mime configuration to karma.conf fixed a similar issue for me:
To debug in Chrome define in karma config:
autowatch:true
and define:
singleRun: false
Start your karma test and open in Chrome a page to the karma-server.
The following error was shown in the console:
Refused to execute script from
'http://localhost:9876/base/src/app/search-persons/search-
persons.component.spec.ts?fe78e0d6a85c32fb65115ec3fd4e171b9f39ded7'
because its MIME type ('video/mp2t') is not executable.
The mime config that fixed this for me:
mime: {
'text/x-typescript': ['ts']
},
Related
I'm working with protractor cucumber framework and since from the long time i observed is cucumber is not able to find the spec file in the project. I have used the cucumber latest version 6.0.3 it is not able to find the spec file but same code i have run using the cucumber 1.3.3.. can any body tell me what's the difference with this versions? is there any thing i need to update for 6.0.3
Cucumber Dependency - 1.3.3
"cucumber": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/cucumber/-/cucumber-1.3.3.tgz",
"integrity": "sha1-Za+2Xy+T9y2teN8qterPFGCf7C8=",
"requires": {
"camel-case": "^3.0.0",
"cli-table": "^0.3.1",
"co": "^4.6.0",
"colors": "^1.1.2",
"commander": "^2.9.0",
"duration": "^0.2.0",
"figures": "1.7.0",
"gherkin": "^4.1.0",
"glob": "^7.0.0",
"is-generator": "^1.0.2",
"lodash": "^4.0.0",
"stack-chain": "^1.3.5",
"stacktrace-js": "^1.3.0"
}
Cucumber Dependency 6.0.3 Latest
"cucumber": {
"version": "6.0.3",
"resolved": "https://registry.npmjs.org/cucumber/-/cucumber-6.0.3.tgz",
"integrity": "sha512-FSx7xdAQfFjcxp/iRBAuCFSXp2iJP1tF2Q5k/a67YgHiYbnwsD9F+UNv9ZG90LFHNsNQhb+67AmVxHkp4JRDpg==",
"dev": true,
"requires": {
"assertion-error-formatter": "^3.0.0",
"bluebird": "^3.4.1",
"cli-table3": "^0.5.1",
"colors": "^1.1.2",
"commander": "^3.0.1",
"cucumber-expressions": "^8.0.1",
"cucumber-tag-expressions": "^2.0.2",
"duration": "^0.2.1",
"escape-string-regexp": "^2.0.0",
"figures": "^3.0.0",
"gherkin": "5.0.0",
"glob": "^7.1.3",
"indent-string": "^4.0.0",
"is-generator": "^1.0.2",
"is-stream": "^2.0.0",
"knuth-shuffle-seeded": "^1.0.6",
"lodash": "^4.17.14",
"mz": "^2.4.0",
"progress": "^2.0.0",
"resolve": "^1.3.3",
"serialize-error": "^4.1.0",
"stack-chain": "^2.0.0",
"stacktrace-js": "^2.0.0",
"string-argv": "^0.3.0",
"title-case": "^2.1.1",
"util-arity": "^1.0.2",
"verror": "^1.9.0"
}
StepDef
module.exports=function(){
this.Given(/^Open the browser and Load the URL$/,async function(){
await firstBrowser.get(properties.get("url1"));
browser.logger.info("Title of the window is :"+await browser.getTitle());
//screenshots.takesScreenshot("filename");
});
this.When(/^User entered the text in the search box$/,async function(){
firstBrowser.sleep(3000);
await page1.email().sendKeys(testData.Login.CM[0].Username);
browser.sleep(3000);
await page1.password().sendKeys(testData.Login.CM[0].Password);
});
}
Config File
exports.config = {
//seleniumAddress: 'http://localhost:4444/wd/hub',
getPageTimeout: 60000,
allScriptsTimeout: 500000,
directConnect:true,
framework: 'custom',
// path relative to the current config file
frameworkPath: require.resolve('protractor-cucumber-framework'),
capabilities: {
'browserName': 'chrome'
},
ignoreUncaughtExceptions:true,
// Spec patterns are relative to this directory.
specs: [
'H:\\workspace\\Protractor_Cucumber\\src\\FeatureFiles\\Test.feature'
],
cucumberOpts: {
require: 'H:\\workspace\\Protractor_Cucumber\\src\\StepDefFiles\\*.js',
tags: false,
profile: false,
'no-source': true
},
onPrepare: function () {
browser.waitForAngularEnabled(false);
const {Given, Then, When, Before} = require('cucumber');
}
};
i didn't used any cucumber hooks in my test scripts..
What makes them to work different, can some help in this?
One reason is Then/When/Given usage change in cucumber 6.x, you can change few step functions to verify this.
For 1.x step function file looks like
module.exports = function () {
this.Then(/^Then the response status is (.*)$/, function (status) {
assert.equal(this.responseStatus, status)
});
this.When(//, ...)
}
For 6.x step function file looks like
const { Then, When } = require('cucumber');
Then(/^the response status is (.*)$/, function (status) {
assert.equal(this.responseStatus, status)
});
When(//,...)
Another possible reason is need to upgrade protractor-cucumber-framework version which is compatible with the cucumber#6.x
I integrated Material UI into my Svelte project with help of "Svelte Material UI" package.
But it don't contains Material layout-grid component.
I installed it separately using yarn add "#material/layout-grid" command.
But now I'm getting error during build process:
[!] (plugin postcss) Error: Invalid CSS after "...ch $size in map": expected expression (e.g. 1px, bold), was ".keys(variables.$co"
node_modules/#material/layout-grid/mdc-layout-grid.scss
Error: Invalid CSS after "...ch $size in map": expected expression (e.g. 1px, bold), was ".keys(variables.$co"
at options.error (/media/hdd-home/d/WebServers/home/spadmin.org/public_html/todoapp/node_modules/node-sass/lib/index.js:291:26)
So, I gave up resolving it myself.
The project package.json:
{
"name": "svelte-app",
"version": "1.0.0",
"scripts": {
"build": "rollup -c",
"dev": "rollup -c -w",
"start": "sirv ."
},
"devDependencies": {
"#mdi/js": "^5.3.45",
"#rollup/plugin-commonjs": "^12.0.0",
"#rollup/plugin-node-resolve": "^8.0.0",
"#smui/button": "^1.0.0-beta.21",
"#smui/card": "^1.0.0-beta.21",
"#smui/checkbox": "^1.0.0-beta.21",
"#smui/chips": "^1.0.0-beta.21",
"#smui/common": "^1.0.0-beta.21",
"#smui/form-field": "^1.0.0-beta.21",
"#smui/linear-progress": "^1.0.0-beta.21",
"#smui/textfield": "^1.0.0-beta.21",
"#smui/top-app-bar": "^1.0.0-beta.21",
"material": "^0.4.3",
"node-sass": "^4.14.1",
"rollup": "^2.3.4",
"rollup-plugin-copy": "^3.3.0",
"rollup-plugin-livereload": "^1.0.0",
"rollup-plugin-postcss": "^3.1.1",
"rollup-plugin-svelte": "^5.0.3",
"rollup-plugin-terser": "^5.1.2",
"svelte": "^3.0.0",
"svelte-preprocess": "^3.7.4"
},
"dependencies": {
"#material/layout-grid": "^6.0.0",
"sirv-cli": "^0.4.4"
}
}
And here is rollup.config.js
import svelte from 'rollup-plugin-svelte';
import resolve from '#rollup/plugin-node-resolve';
import commonjs from '#rollup/plugin-commonjs';
import copy from 'rollup-plugin-copy';
import livereload from 'rollup-plugin-livereload';
import {terser} from 'rollup-plugin-terser';
import postcss from 'rollup-plugin-postcss';
import autoPreprocess from 'svelte-preprocess';
const production = !process.env.ROLLUP_WATCH;
export default {
input: 'src/main.js',
output: {
sourcemap: true,
format: 'iife',
name: 'app',
file: 'scripts/app.js',
},
plugins: [
copy({
targets: [
{src: 'src/index.html', dest: '.'},
],
}),
svelte({
dev: !production,
emitCss: true,
css: css => {
css.write('css/app.css');
},
preprocess: autoPreprocess()
}),
resolve({
browser: true,
dedupe: ['svelte', '#material'],
}),
commonjs(),
postcss({
extract: 'css/app.css',
minimize: true,
sourceMap: true,
use: [
[
'sass', {
includePaths: [
'./theme',
'./node_modules',
],
},
],
],
}),
!production && serve(),
!production && livereload({watch: ['scripts', 'css', 'src', 'theme']}),
production && terser(),
],
watch: {
clearScreen: false,
},
};
function serve() {
let started = false;
return {
writeBundle() {
if (!started) {
started = true;
require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], {
stdio: ['ignore', 'inherit', 'inherit'],
shell: true,
});
}
},
};
}
It clearly tries to parse the scss file as css. So it probably misses the compile step. I can't find the scss rollup plugin in your package.json.
Check this, it could solve your problem: https://www.npmjs.com/package/rollup-plugin-scss
I'm having problems getting prettier, eslint and visual studio code play nice together. I keep seeing red errors such as this in VSCode:
[eslint] Replace `↹` with `··` (prettier/prettier)
I have VSCode plugins eslint and prettier installed.
VSCode config
{
"javascript.validate.enable": false,
"javascript.format.enable": false,
"editor.formatOnSave": true,
"prettier.singleQuote": true,
"prettier.eslintIntegration": true,
"window.zoomLevel": -1,
"editor.fontSize": 13
}
.eslintrc
{
"parser": "babel-eslint",
"extends": [
"airbnb",
"plugin:react-native/all",
"prettier",
"prettier/react",
"prettier/standard"
],
"parserOptions": {
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"env": {
"browser": true,
"node": true,
"mocha": true,
"jest": true,
"es6": true
},
"globals": {
"expect": true,
"sinon": true,
"Promise": true,
"__DEV__": true
},
"plugins": ["babel", "react", "react-native", "prettier"],
"settings": {
"import/resolver": {
"node": {
"paths": ["app"]
}
}
},
"rules": {
"prettier/prettier": ["error"],
"indent": [2, "tab", { "SwitchCase": 1 }],
"comma-dangle": [2, "only-multiline"],
"react/jsx-indent": [0, "tab"],
"jsx-quotes": [2, "prefer-double"],
"react/display-name": 0,
"react/jsx-boolean-value": 1,
"react/jsx-no-undef": 2,
"react/jsx-sort-prop-types": 0,
"react/jsx-sort-props": 0,
"react/jsx-uses-react": 1,
"react/jsx-uses-vars": 1,
"react/jsx-filename-extension": 0,
"react/no-did-mount-set-state": 2, // [2, "allow-in-func"],
"react/no-did-update-set-state": 2,
"react/no-multi-comp": 0,
"react/no-unknown-property": 2,
"react/prop-types": 1,
"react/react-in-jsx-scope": 2,
"react/self-closing-comp": 1,
"react/sort-comp": 2,
"react/jsx-wrap-multilines": 2,
"react-native/no-color-literals": 1,
"quotes": [
2,
"single",
"avoid-escape"
]
}
}
dev dependencies package.json
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-eslint": "^7.2.3",
"babel-plugin-module-resolver": "3.0.0-beta.5",
"babel-plugin-react-intl": "^2.3.1",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-es2015-modules-commonjs": "^6.24.1",
"babel-preset-airbnb": "^2.4.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-react-native": "^4.0.0",
"babel-preset-react-native-stage-0": "^1.0.1",
"babel-register": "^6.24.1",
"chai": "^4.1.0",
"chai-as-promised": "^7.1.1",
"chai-enzyme": "^0.8.0",
"chai-immutable": "^1.6.0",
"commitizen": "^2.9.6",
"cz-conventional-changelog": "^2.0.0",
"enzyme": "^3.1.0",
"enzyme-adapter-react-16": "^1.0.2",
"enzyme-to-json": "^3.1.4",
"eslint": "^4.7.2",
"eslint-config-airbnb": "^15.1.0",
"eslint-config-prettier": "^2.7.0",
"eslint-plugin-babel": "^4.1.2",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-jsx-a11y": "^6.0.2",
"eslint-plugin-prettier": "^2.3.1",
"eslint-plugin-react": "^7.4.0",
"eslint-plugin-react-native": "^3.1.0",
"eslint-plugin-standard": "^3.0.1",
"expect.js": "^0.3.1",
"flow": "^0.2.3",
"flow-bin": "^0.56.0",
"immutablediff": "^0.4.3",
"jest": "^21.2.1",
"jshint": "^2.9.5",
"mocha": "^3.4.2",
"prettier-eslint": "^8.2.1",
"react-addons-test-utils": "^15.6.2",
"react-dom": "16.0.0-beta.5",
"react-intl-cra": "^0.2.8",
"react-native-mock": "^0.3.1",
"react-test-renderer": "^16.0.0",
"redux-debounce": "^1.0.1",
"redux-debounced": "^0.4.0",
"redux-devtools": "^3.4.0",
"redux-devtools-dock-monitor": "^1.1.2",
"redux-devtools-log-monitor": "^1.3.0",
"redux-mock-store": "^1.2.3",
"regenerator-runtime": "^0.11.0",
"remote-redux-devtools": "^0.5.12",
"sinon": "^4.0.0"
}
You have to install eslint-config-prettier package and in your eslint config file add prettier to the extends array
{
extends: ['prettier']
}
The solution I found was to modify the Visual Studio Code settings to format files when saving "editor.formatOnSave": true and run ESLint when saving files "eslint.run": "onSave". You can find a more detailed explanation at Prettier Formatter for Visual Studio Code.
npm run lint -- --fix
It's ok for me but you have to deactivate the Prettier extension to avoid conflicts.
When I used this part into .eslintrc file, that works for my code.
"extends": [
"plugin:react/essential",
],
Solved using fix
yarn run lint --fix
Had the same issue.
{
"useTabs": false
}
This fixed my issue
Hello friends i testing my angular 2 app using protractor and cucumber js but it give me this error i try several solution for this issue but no one can solve my issue.if you know any sol it would be great thank u..
[1] Unhandled rejection TypeError: this.registerHandler is not a function
[1] at Object.registerHandlers (/home/ca1/WebstormProjects/DME/node_modules/protractor-cucumber-framework/lib/resultsCapturer.js:16:8)
[1] at /home/ca1/WebstormProjects/DME/node_modules/protractor-cucumber-framework/lib/resultsCapturer.js:6:22
[1] at Object.defineSupportCode (/home/ca1/WebstormProjects/DME/node_modules/cucumber/src/support_code_library_builder/index.js:20:9)
[1] at Object. (/home/ca1/WebstormProjects/DME/node_modules/protractor-cucumber-framework/lib/resultsCapturer.js:5:12)
[1] at Module._compile (module.js:570:32)
[1] at Object.Module._extensions..js (module.js:579:10)
[1] at Module.load (module.js:487:32)
[1] at tryModuleLoad (module.js:446:12)
[1] at Function.Module._load (module.js:438:3)
[1] at Module.require (module.js:497:17)
[1] at require (internal/module.js:20:19)
[1] at /home/ca1/WebstormProjects/DME/node_modules/cucumber/src/cli/index.js:61:42
[1] at Array.forEach (native)
[1] at Cli.getSupportCodeLibrary (/home/ca1/WebstormProjects/DME/node_modules/cucumber/src/cli/index.js:61:22)
[1] at Cli. (/home/ca1/WebstormProjects/DME/node_modules/cucumber/src/cli/index.js:76:37)
[1] at next (native)
[1] [17:30:50] E/launcher - BUG: launcher exited with 1 tasks remaining
here is my package.json
{
"name": "dpt-angular",
"version": "1.0.0",
"description": "QuickStart package.json from the documentation, supplemented with testing support",
"scripts": {
"start": "concurrently \"npm run tsc:w\" \"npm run lite\" ",
"e2e": "concurrently \"http-server -s\" \"protractor protractor.config.js\" --kill-others --success first",
"lint": "tslint ./app/**/*.ts -t verbose",
"lite": "lite-server",
"pree2e": "webdriver-manager update",
"test": "concurrently \"tsc -w\" \"karma start karma.conf.js\"",
"test-once": "karma start karma.conf.js --single-run",
"tsc": "tsc",
"tsc:w": "tsc -w"
},
"keywords": [],
"author": "",
"license": "MIT",
"dependencies": {
"#angular/common": "~2.4.0",
"#angular/compiler": "~2.4.0",
"#angular/core": "~2.4.0",
"#angular/forms": "~2.4.0",
"#angular/http": "~2.4.0",
"#angular/platform-browser": "~2.4.0",
"#angular/platform-browser-dynamic": "~2.4.0",
"#angular/router": "~3.4.0",
"#types/file-saver": "0.0.1",
"angular-in-memory-web-api": "~0.2.4",
"angular2-moment": "^1.1.0",
"core-js": "^2.4.1",
"mydatepicker": "^2.0.25",
"ng2-completer": "^1.5.2",
"ng2-file-upload": "^1.2.1",
"ng2-pdf-viewer": "^1.1.0",
"rxjs": "5.0.1",
"systemjs": "0.19.40",
"zone.js": "^0.7.4"
},
"devDependencies": {
"#types/jasmine": "^2.5.36",
"#types/node": "^6.0.46",
"canonical-path": "0.0.2",
"concurrently": "^3.1.0",
"cucumber": "^3.0.0",
"cucumber-tsflow": "^2.2.0",
"http-server": "^0.9.0",
"jasmine-core": "~2.4.1",
"karma": "^1.3.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-jasmine-html-reporter": "^0.2.2",
"lite-server": "^2.2.2",
"lodash": "^4.16.4",
"protractor": "^4.0.14",
"protractor-cucumber-framework": "^3.0.0",
"rimraf": "^2.5.4",
"ts-node": "^3.3.0",
"tslint": "^3.15.1",
"typescript": "~2.3.4",
"webdriver-manager": "^12.0.6"
},
"repository": {}
}
and my protractor.conf.json
var fs = require('fs');
var path = require('canonical-path');
var _ = require('lodash');
exports.config = {
directConnect: true,
// Capabilities to be passed to the webdriver instance.
capabilities: {
'browserName': 'chrome'
},
allScriptsTimeout:90000,
getPageTimeout:400000,
ignoreUncaughtExceptions: true,
framework: 'custom',
frameworkPath: require.resolve('protractor-cucumber-framework'),
// Spec patterns are relative to this config file
specs: ['**/cucumber_test/*.feature' ],
cucumberOpts: {
compiler: "ts:ts-node/register",
require: ['**/*e2e-spec.js'], // require step definition files before executing features
tags: '#TypeScriptScenario,#dev,#AddScenario,#SubtractScenario,#MultiplyScenario,#DivideScenario,#ModulusScenario', // <string[]> (expression) only execute the features or scenarios with tags matching the expression
strict: true, // <boolean> fail if there are any undefined or pending steps
format: ["pretty"], // <string[]> (type[:path]) specify the output format, optionally supply PATH to redirect formatter output (repeatable)
dryRun: false, // <boolean> invoke formatters without executing steps
'fail-fast': true
},
// For angular tests
useAllAngular2AppRoots: true,
// Base URL for application server
baseUrl: 'http://localhost:3000',
// doesn't seem to work.
// resultJsonOutputFile: "foo.json",
onPrepare: function() {
//// SpecReporter
//var SpecReporter = require('jasmine-spec-reporter');
//jasmine.getEnv().addReporter(new SpecReporter({displayStacktrace: 'none'}));
//// jasmine.getEnv().addReporter(new SpecReporter({displayStacktrace: 'all'}));
// debugging
// console.log('browser.params:' + JSON.stringify(browser.params));
/*jasmine.getEnv().addReporter(new Reporter( browser.params )) ;*/
// Allow changing bootstrap mode to NG1 for upgrade tests
global.setProtractorToNg1Mode = function() {
browser.useAllAngular2AppRoots = false;
browser.rootEl = 'body';
};
// browser.manage().window().maximize();
},
/*jasmineNodeOpts: {
// defaultTimeoutInterval: 60000,
defaultTimeoutInterval: 10000,
showTiming: true,
print: function() {}
}*/
}
This issue will be solved just downgrading the cucumber version 3 to 2.
Good Morning,
I am having a weird issue that I cannot seem to solve. I have my Karma tests written out and the execute correctly, but when I try to wire up the code coverage for Karma it just spits out 100% no matter what.
I looked at the other questions that were raised here and none of them seemed to solve my issue. Any help would be greatly appreciated.
Using:
"karma": "~0.12.37",
"karma-babel-preprocessor": "^5.2.1",
"karma-browserify": "^4.2.1",
"karma-coverage": "^0.4.2",
"karma-jasmine": "~0.3.5",
"karma-phantomjs-launcher": "^0.2.0",
Here is my karma.conf.js
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['browserify', 'jasmine'],
files: [
'bower_components/jquery/dist/jquery.js',
'bower_components/angular/angular.js',
'bower_components/angular-animate/angular-animate.js',
'bower_components/angular-cookies/angular-cookies.js',
'bower_components/angular-mocks/angular-mocks.js',
'bower_components/angular-resource/angular-resource.js',
'bower_components/angular-sanitize/angular-sanitize.js',
'bower_components/angular-touch/angular-touch.js',
'bower_components/angular-ui-router/release/angular-ui-router.js'
'src/*.html',
'src/**/*.html',
'src/app/index.js',
'src/app/**/*.js'
],
exclude: [],
preprocessors: {
'src/app/index.js': ['browserify', 'coverage'],
'src/app/**/*.js': ['browserify', 'coverage']
},
browserify: {
debug: true,
transform: ['babelify', 'stringify']
},
reporters: ['progress', 'coverage'],
port: 9876,
colors: true,
autoWatch: true,
browsers: ['PhantomJS'],
singleRun: false
});
};
My file structure is:
src
app
login
login.controller.js
login.controller.spec.js
login.html
index.js
karma.conf.js
Thank you!
Have you tried using browserify-istanbul transform?
module.exports = function(config) {
config.set({
// ...
browserify: {
transform: ['browserify-istanbul', ...]
}
});
};
You need to "instrument" your code to collect coverage metrics. So you should tell browserify to apply instrumentation before returning the module with require.