I have multiple suites in protractor which i want to test and run.It runs fine on Mozilla Firefox but only the first suite runs while using Google chrome(Version 51.0.2704.84 (64-bit)
suites: {
lawfirm: [
'../Test_Suites/Lawfirm/signUp_spec.js',
'../Test_Suites/Lawfirm/login_spec.js',
],
beneficiary : [
'../Test_Suites/Beneficiary/loginBeneficiary_spec.js',
]
},
Protractor Version : 3.3.0
You don't need to make suites an array, just use * to denote all files under a certain directory.
suites: {
lawfirm: '../Test_Suites/Lawfirm/*.spec.js'
}
Then run as you would normally:
protractor conf.js --suite lawfirm
You don't need to put an array. Just a comma separated list (no spaces after the comma either)
suites:{
suite1:'....','....',
suite2:'...','....'
}
Here is where you can find more information on the protractor config setup:
https://github.com/angular/protractor/blob/master/docs/referenceConf.js
Related
I am trying to do unit testing of my React app using Enzyme with Jest but getting this error
` FAIL src/components/XYZ/tests/ABC.test.js
● Test suite failed to run
SyntaxError: Name argument is not a valid custom element name.
Test Suites: 2 failed, 2 total
Tests: 0 total
Snapshots: 0 total
Time: 3.224 s
Ran all test suites.`
My Jest Config file is as following
"jest": {
"moduleNameMapper": {
"d3": "<rootDir>/node_modules/d3/dist/d3.min.js",
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__mocks__/fileMock.js",
"^.+\\.(css|less|scss)$": "identity-obj-proxy"
},
"setupFiles": [
"./src/"
],
"setupFilesAfterEnv": [
"./src/setUpTests.js"
],
"testPathIgnorePatterns": [
"./node_modules/"
]
},
Please let me know what I am doing wrong here ? TIA
I think the configuration used for setupFiles is wrong here. As per jest documentation
https://jestjs.io/docs/configuration#setupfiles-array
setUpFiles is used for "A list of paths to modules that run some code to configure or set up the testing environment. Each setupFile will be run once per test file. Since every test runs in its own environment, these scripts will be executed in the testing environment before executing setupFilesAfterEnv and before the test code itself. "
Please either remove setUpFiles or use proper file path here .
I am using JEST to unit test my app. The test execution is running fine. However I am not able to collect code coverage correctly. The coverage is only logged for folder where I have the jest config file. Snapshot of folder structure:
In the console the coverage is only generated for enzyme-config.js. I tried using "collectCoverageFrom" : ["**/src/**/*.js"] but it throws me Unknown for all params. Am I missing something here?
jest-setup.json:
{
"testEnvironment": "jsdom",
"setupTestFrameworkScriptFile": "./enzyme.setup.js",
"testResultsProcessor": "jest-teamcity-reporter",
"coverageReporters": [
"teamcity", "lcov", "text"
],
"collectCoverageFrom" : ["**/src/**/*.js"],
"roots": [
"../../../__tests__/unit"
]
}
Coverage log:
A double star notation (**) like you are using in your collectCoverageFrom array, will only match file and folders which are in or in subfolders of the current folder. Assuming jest will match these files based on the folder in which the setup is defined, it will not find any files outside of the subtree which it is in. You might want to try ../src/**/*.js.
I have a working webdriver javascript test script for my html page that runs using ChromeDriver without needing to start up a selenium standalone server:
test.js
'use strict';
var path = require('path');
var webdriver = require('selenium-webdriver');
var chrome = require('selenium-webdriver/chrome');
var options = new chrome.Options();
var logging_prefs = new webdriver.logging.Preferences();
logging_prefs.setLevel(webdriver.logging.Type.BROWSER, webdriver.logging.Level.ALL);
options.setLoggingPrefs(logging_prefs);
var driver = new webdriver.Builder().withCapabilities(options.toCapabilities()).build();
driver.get('file://' + path.resolve('./index.html'));
// Do some testing
driver.quit();
I want to port this test to use theintern.io, but I'd prefer not to have to run a standalone selenium server. Is this possible?
[Edit: Add info on the error and theintern config]
I see the error [POST http://localhost:4444/wd/hub/session] connect ECONNREFUSED which I guess is because I don't have the standalone server running.
My theintern config looks like this:
define({
environments: [
{ browserName: 'chrome' }
],
// Name of the tunnel class to use for WebDriver tests
tunnel: 'NullTunnel',
// Non-functional test suite(s) to run in each browser
suites: [ /* 'myPackage/tests/foo', 'myPackage/tests/bar' */ ],
// Functional test suite(s) to run in each browser once non-functional tests are completed
functionalSuites: [ 'tests/functional/index' ],
// A regular expression matching URLs to files that should not be included in code coverage analysis
excludeInstrumentation: /^(?:tests|node_modules)\//
});
My theintern test looks like this:
define([
'intern!object',
'intern/chai!assert',
'require'
], function (registerSuite, assert, require) {
registerSuite({
name: 'index',
'first test': function () {
return this.remote
.get(require.toUrl('index.html'))
... //more test logic
}
});
});
Intern speaks the standard WebDriver protocol so can be used with any server that implements the specification, not just Selenium. In this case if you are trying to connect to ChromeDriver just make sure that it is running first (chromedriver --port=4444 --url-base=wd/hub) and then run intern-runner config=mid/of/config and you should be good to go with the configuration that you currently have.
I have an AngularJS app that I am using end-to-end testing on. This app relies on Protractor and Jasmine for testing. I'm running my tests via a Grunt task.
Does anyone know of a task or a way to display a summary of Protractor's test results in the command line? Currently, I have time-grunt to display a summary of how long each task took. I'd love to have the ability to show something like 'Ran [x] tests. [y] Succeeded. [z] Failed.'
Thank you
You can add a consoleReporter. It's a little more verbose, but it does give a summary at the end.
Using jasmine-reporters you can add several reporters. My favorite is the HtmlReporter that takes screenshots when the test fails. Below is an example of several reporters configured in the protractor.conf.js
onPrepare: function () {
require('jasmine-reporters');
jasmine.getEnv().addReporter(new jasmine.JUnitXmlReporter('reports', true, true));
jasmine.getEnv().addReporter(new jasmine.ConsoleReporter());
jasmine.getEnv().addReporter(new HtmlReporter({
baseDirectory: 'reports/screenshots' ,
takeScreenShotsOnlyForFailedSpecs: true
}));
},
If you want to tweak what you display in the console you can use jasmine-spec-reporter:
I am successfully unit testing my coffeescript / angularjs code using karma / jasmine.
One of my tests is failing and so I would like to place breakpoints in my coffeescript code.
I understand that I will need to provide source-maps to allow WebStorm 7 to correlate the transpiled javascript to the original coffeescript (see karma config below).
These questions were useful to get me started but have not completely solved the problem:
webstorm 7/karma server looking for wrong sourcemap file when debugging coffeescript
Using Karma-runner with AngularJS, Jasmine, CoffeScript
Now, when I debug, any coffeescript file that has a breakpoint in it will suspend but not on the breakpoint, typically on the first line of the file or the function that contains the breakpoint.
Continuing the execution simply runs to the end and the inner breakpoint is not hit.
Attempting to step through the coffeescript takes me into the jasmine.js code. As I continue to step-through the jasmine code the test suite eventually completes but the breakpoint is never hit.
Here is the relevant portion of my karma config.
karma.config.js
files: [
'App.UnitTests/lib/http_ajax.googleapis.com_ajax_libs_angularjs_1.2.0-rc.2_angular.js',
'App.UnitTests/lib/http_ajax.googleapis.com_ajax_libs_angularjs_1.2.0-rc.2_angular-sanitize.js',
'App.UnitTests/lib/http_angular-ui.github.io_ui-router_release_angular-ui-router.js',
'App.UnitTests/lib/http_ajax.googleapis.com_ajax_libs_angularjs_1.2.0-rc.2__angular-mocks.js',
'App.FrontEnd/coffee/**/*.coffee',
'App.UnitTests/tests/**/*.spec.coffee'
],
preprocessors : {
'App.FrontEnd/coffee/**/*.coffee':'coffee',
'App.UnitTests/tests/**/*.spec.coffee':'coffee'
},
coffeePreprocessor: {
options: { bare: true, sourceMap: true },
transformPath: function ( path ) { return path.replace( /.js$/, '.coffee' ); }
},