I am using json reporter to generate the JSON report for all the suites. below is the code.
export const config: WebdriverIO.Config = {
autoCompileOpts: {
autoCompile: true,
tsNodeOpts: {
transpileOnly: true,
project: 'test/tsconfig.json'
}
},
baseUrl: 'URL',
suites: {
bwincom: [
[
"test/offers/OfferCategory/offersCategory.annonymous.e2e-spec.ts",
"test/offers/OfferCategory/OfferExpiryText-spec.ts"
]
]
},
capabilities: [{
maxInstances: 1,
browserName: 'chrome',
acceptInsecureCerts: true
}],
framework: 'jasmine',
reporters: [
['json', {
outputDir: './Results',
}]
]
}
Issue: If I pass two spec test cases in suites, it'll generate the result twice for each test case. And If I pass three spec test cases in suites, it'll generate the result thrice for each test case. Expected is the result should not be duplicated and it should generate only one log for each suite.
Related
I am using codeceptJS with webdriverio Selenium standalone server. my problem is how do i load my unpacked chrome extension when i run tests. i’ve been searching for the solution from past 2 days but couldn’t find a solution. all i get is some java code from searches.
first of all thank you very much both of you wOxxOm && Yandimirkin Vladislav
what i did was added few lines into codecept.conf.js
desiredCapabilities: {
chromeOptions: {
args: [ "--load-extension=D:/Projects/dpl/dist", "--disable-gpu", "--window-size=1366,768" ]
}
}
Here is what codecept.conf.js looks like now:
exports.config = {
tests: './*_test.js',
output: './output',
helpers: {
WebDriver: {
url: 'http://localhost',
browser: 'chrome',
desiredCapabilities: {
chromeOptions: {
args: [ "--load-extension=D:/Projects/dpl/dist", "--disable-gpu", "--window-size=1366,768" ]
}
}
},
ResembleHelper : {
require: "codeceptjs-resemblehelper",
screenshotFolder : "./tests/output/",
baseFolder: "./tests/screenshots/base/",
diffFolder: "./tests/screenshots/diff/"
}
},
plugins: {
wdio: {
enabled: true,
services: ['selenium-standalone']
}
},
include: {},
bootstrap: null,
mocha: {},
name: 'codecept'
}
1) Add to you
capababilies: { extensions: extensionsToLoad }
Where extensionsToLoad is array of base64 encoded extensions, something like this
fs.readFileSync("./test.crx").toString("base64")
I have a bunch of tests that are totaly ignored.
I also looked for everywhere in the project for fdescribe, fit, xdescribe, xit, ddescribe or iit but there are none remainning. I just have a few xit but not much.
It seems to ignore all tests in a my /modules/ folder but it doesn't seem to be caused by misconfiguration because if I use fdescribe on some of them those are executed properly. Here is my karma.conf.js anyway in case you are intrested :
'use strict';
const stringify = require('stringify');
const babelify = require('babelify');
module.exports = (config) => {
config.set({
basePath: '',
frameworks: ['browserify', 'jasmine'],
files: [
'node_modules/jquery/dist/jquery.min.js',
'node_modules/angular/angular.js',
'node_modules/angular-route/angular-route.min.js',
'node_modules/angular-permission/dist/angular-permission.js',
'node_modules/angular-permission/dist/angular-permission-ng.js',
'node_modules/angular-sanitize/angular-sanitize.min.js',
'node_modules/angular-messages/angular-messages.min.js',
'node_modules/angular-mocks/angular-mocks.js',
'src/apps/publiques/app-publiques.module.js',
'src/apps/publiques/bootstrap-test.js',
'src/**/*.spec.js'
],
// the only folder that is excluded is correctly excluded
exclude: [
'src/modules/data-table/**/*.spec.js'
],
preprocessors: {
'src/apps/publiques/app-publiques.module.js': 'browserify',
'src/apps/publiques/bootstrap-test.js': 'browserify',
'src/**/*.spec.js': 'browserify',
},
browsers: ['PhantomJS'],
plugins: [
'karma-phantomjs-launcher',
'karma-jasmine',
'karma-browserify',
'karma-coverage',
'karma-mocha-reporter',
'karma-narrow-reporter',
'karma-jasmine-diff-reporter',
'karma-spec-reporter',
],
browserify: {
debug: true,
transform: [
babelify,
stringify,
],
},
reporters: [
'jasmine-diff',
// 'progress',
// 'mocha',
'narrow',
// 'spec'
],
specReporter: {
maxLogLines: 5, // limit number of lines logged per test
suppressErrorSummary: false, // do not print error summary
suppressFailed: false, // do not print information about failed tests
suppressPassed: false, // do not print information about passed tests
suppressSkipped: true, // do not print information about skipped tests
showSpecTiming: true, // print the time elapsed for each spec
failFast: true // test would finish with error when a first fail occurs.
},
mochaReporter: {
colors: {
success: 'green',
info: 'blue',
warning: 'yellow',
error: 'bgRed',
},
symbols: {
success: '+',
info: '#',
warning: '!',
error: 'x',
},
output: 'full',
},
phantomjsLauncher: {
exitOnResourceError: true,
},
port: 9876,
logLevel: config.LOG_DEBUG,
singleRun: true,
colors: true,
autoWatch: false,
});
};
End of karma log is
PhantomJS 2.1.1 (Windows 7 0.0.0) LOG: 'WARNING: Tried to load angular more than once.'
PhantomJS 2.1.1 (Windows 7 0.0.0): Executed 177 of 637 (skipped 10) SUCCESS
(0.858 secs / 0.82 secs)
[17:51:39] Karma Run Complete: No Failures
It turned out I had to beforeEach nested somewher like follow
describe('publiques-demandes-modifier.controller', () => {
beforeEach(() => {
angular.mock.module(app);
// mock window pour le test submitRedirect
const windowObj = { location: { href: '' } };
beforeEach(angular.mock.module(($provide) => {
$provide.value('$window', windowObj);
}));
angular.mock.inject((
I found out by using mocha reporter and by skipping last executed tests one by one to find the one responsible.
I am trying to set up code coverage for an ES6 react project. I got karma with code coverage to work, but its showing inaccurate numbers for the code coverage. I currently don't have any unit test written and its showing coverage for files. Here is my karma config file
var istanbul = require('browserify-istanbul');
module.exports = function (config) {
config.set({
base: './',
browsers: ['Chrome'],
singleRun: false,
autoWatch: true,
frameworks : [ 'jasmine', 'browserify'],
files: [
'js/**/*.js'
],
exclude: [ 'js/app.js' ],
preprocessors: {
'js/**/*.js': [ 'browserify' ]
},
browserify: {
configure: function(bundle){
bundle.on('prebundle', function(){
bundle
.transform(istanbul)
})
},
transform: [
['babelify', { presets: ['es2015', 'react'] }]
],
debug: true, // make stack traces readable.
},
reporters: [ 'progress', 'dots', 'coverage' ],
coverageReporter: {
type : 'text',
dir : 'coverage/'
}
});
};
The output is this
All files | 72.72 | 40.35 | 48.72 | 71.28 |
I'm just starting to add parallel testing to my config file and I'm running into an issue that I'm having trouble discerning elsewhere if its possible or not from Protractor. My multiCapabilities set up looks like this at the moment:
multiCapabilities:[{
browserName: 'chrome',
name: 'chrome-tests',
count: 1,
shardTestFiles: true,
maxInstances: 1,
suites: {
repeatable: 'example/example.spec.js'
}
}, {
browserName: 'firefox',
name: 'ff-tests',
count: 1,
shardTestFiles: true,
maxInstances: 1,
suites: {
repeatable: 'example/example.spec.js'
}
}],
and it fails with an error message of:
Cannot read property 'repeatable' of undefined
Am I missing something or does multiCapability not support suites running in parallel?
suites can only be defined on the upper level in your config. They cannot be capability-specific.
I keep trying to run some E2E tests out of ToT angular-seed master and keep getting the following error when I run ./scripts/e2e-test.sh:
TypeError: Property 'browser' of object #<Object> is not a function
I get this error when trying to run the following piece of code as one of my e2e scenario:
'use strict';
/* https://github.com/angular/protractor/blob/master/docs/getting-started.md */
describe('MyApp', function() {
describe(Index', function() {
beforeEach(function() {
browser().navigateTo('/');
});
it('should render feature specific image', function() {
expect(element('img.featurette-image').length).toBe('4');
});
});
});
I'm wondering if my protractor config is incorrect:
exports.config = {
allScriptsTimeout: 11000,
specs: [
'../test/e2e/*.js'
],
capabilities: {
'browserName': 'chrome'
},
baseUrl: 'http://localhost:3000/',
framework: 'jasmine',
jasmineNodeOpts: {
defaultTimeoutInterval: 30000
}
};
My unit tests are running just fine. This is the Karma config I have for them (note that this is an angular app within the public director of a sinatra application listening on port 3000:
module.exports = function(config){
config.set({
basePath : '../',
files : [
'https://code.jquery.com/jquery-1.10.2.min.js',
'app/lib/angular/angular.js',
'app/lib/angular/angular-*.js',
'test/lib/angular/angular-mocks.js',
'app/js/**/*.js',
'test/unit/**/*.js'
],
exclude : [
'app/lib/angular/angular-loader.js',
'app/lib/angular/*.min.js',
'app/lib/angular/angular-scenario.js'
],
autoWatch : true,
frameworks: ['jasmine'],
browsers : ['Chrome'],
plugins : [
'karma-junit-reporter',
'karma-chrome-launcher',
'karma-firefox-launcher',
'karma-jasmine'
],
junitReporter : {
outputFile: 'test_out/unit.xml',
suite: 'unit'
}
})}
Thanks for the help!
You need to change this line:
browser().navigateTo('/');
to
browser.navigateTo('/');
That's it.