Timeouts testing polymer elements with web-component-tester and sauce labs - polymer

We're having trouble testing our polymer elements with web-component-tester and Sauce Labs. When we try to test with more browsers than our subscription level allows to run simultaneously, the tests that don't run immediately eventually time out. It seems really wrong that sauce labs and/or WCT doesn't know how to wait to begin executing a test until the other tests are finished, so that we can queue up as many tests as we wish without having to worry about VM utilization.
Has anyone figured this out? Thanks.
Here is our wct.conf.js in case it helps:
module.exports = {
testTimeout: 600 * 1000,
persistent: false,
ttyOutput: false,
verbose: false,
expanded: true,
browserOptions: {
name: "TWT Component Tests"
},
suites: [
'elements/twt-elements/test/index.html'
],
root: 'app',
webserver: {
pathMappings: [
{'/secrets.json': '../db/secrets.json'},
],
},
plugins: {
local: {
disabled: false,
browsers: ['chrome', 'safari', 'canary', 'firefox']
},
sauce: {
disabled: false,
commandTimeout: 600,
idleTimeout: 180,
browsers: [
/* see https://docs.saucelabs.com/reference/platforms-configurator */
/* support matrix: https://docs.google.com/spreadsheets/d/1XqTxODsi2s2GGllld1yHImtb-2ubCX1XbRsvZ4DqpZI */
{
browserName: "chrome",
platform: "OS X 10.9",
version: "40"
},
{
browserName: "safari",
platform: "OS X 10.9",
version: "7.0"
},
{
browserName: "safari",
platform: "OS X 10.10",
version: "8.0"
},
{
browserName: "chrome",
platform: "Windows 8.1",
version: "40"
},
{
browserName: "internet explorer",
platform: "Windows 8.1",
version: "11.0"
},
{
browserName: "firefox",
platform: "Windows 7",
version: "27.0"
},
{
browserName: "internet explorer",
platform: "Windows 7",
version: "10.0"
},
]
}
}
};

Related

Webpack, babelrc dynamic import not working

I spent quite some time trying to figure this out myself but here I am, with no more options to consider than to reach out to the community for some guidance.
I am trying to do something very simple in principle, dynamically import a component with WebPack, using ES6 modules and babelrc.
I have the following app architecture:
-root
-- root/.webpack.dev.js
-- root/.webpack.prod.js
-- root/.babelrc
-- root/package.json
-- root/node_modules/
-- root/dist/
-- root/src/
--- root/src/index.js
--- root/src/modules/
--- root/src/modules/module1.js
--- root/src/modules/module2.js
--- root/src/modules/module3.js
--- root/src/modules/module4.js
--- root/src/modules/module5.js
In my module1.js (not the real name) I am using the following code to dynamically import module2.js:
async function load(configObject) {
const {
init,
requestPermissions
} = await import( /* webpackChunkName: "chunkname" */ `./module2.js`)
init(configObject)
_namespace.requestPermissions = requestPermissions;
}
My .babelrc file:
{
"presets": [
["#babel/preset-env", {
"targets": "> 0.25%, not dead"
}]
],
"plugins": ["#babel/plugin-syntax-dynamic-import",
["#babel/plugin-transform-runtime",
{
"regenerator": true
}
],
],
"comments": true
}
// "#babel/preset-env"
My Webpack config:
const path = require('path');
const webpack = require('webpack')
const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin
const WorkboxPlugin = require('workbox-webpack-plugin');
const {
InjectManifest
} = require('workbox-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
module.exports = {
entry: {
lib: "./src/index.js"
},
mode: 'development',
module: {
rules: [{
test: /\.js$/,
use: [{
loader: "babel-loader"
}],
exclude: /node_modules/
}]
},
optimization: {
minimizer: [new TerserPlugin({
test: /\.js(\?.*)?$/i,
parallel: true,
cache: true,
terserOptions: {
ecma: 8,
warnings: false,
parse: {
ecma: 8,
},
compress: {
warnings: false,
comparisons: false,
},
mangle: {
safari10: true,
},
module: false,
output: {
ecma: 5,
comments: false,
ascii_only: true,
},
toplevel: false,
nameCache: null,
ie8: false,
keep_classnames: undefined,
keep_fnames: false,
safari10: false,
},
})],
},
output: {
filename: '[name].js',
chunkFilename: '[name].bundle.js',
path: path.resolve(__dirname, 'dist'),
publicPath: "/"
},
devServer: {
contentBase: "dist",
compress: true,
stats: {
colors: true
},
overlay: true
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('development'),
'API_URL': JSON.stringify('ENDPOINT')
}
}),
new BundleAnalyzerPlugin({
generateStatsFile: true
}),
new WorkboxPlugin.GenerateSW({
"swDest": "firebase-messaging-sw.js",
}),
new InjectManifest({
"swSrc": path.join('src', 'firebase-messaging-sw.js')
})
]
};
My package.json:
{
"name": "refactor",
"version": "1.0.0",
"description": "",
"main": "backuprefacto.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "NODE_ENV=production webpack --config=webpack.prod.js",
"build:dev": "webpack --config=webpack.dev.js",
"start": "webpack-dev-server --config=webpack.dev.js"
},
"keywords": [],
"private": true,
"license": "ISC",
"devDependencies": {
"#babel/plugin-syntax-dynamic-import": "^7.2.0",
"#babel/preset-env": "^7.5.5",
"babel-loader": "^8.0.6",
"babel-minify": "^0.5.1",
"babel-minify-webpack-plugin": "^0.3.1",
"babel-plugin-syntax-dynamic-import": "^6.18.0",
"terser-webpack-plugin": "^1.4.1",
"uglifyjs-webpack-plugin": "^2.2.0",
"webpack": "^4.39.2",
"webpack-bundle-analyzer": "^3.4.1",
"webpack-cli": "^3.3.7",
"webpack-dev-server": "^3.8.0",
"workbox-webpack-plugin": "^4.3.1"
},
"dependencies": {
"#babel/core": "^7.5.5",
"#babel/plugin-transform-runtime": "^7.5.5",
"#babel/runtime": "^7.5.5",
"firebase": "^6.4.0",
"save": "^2.4.0"
}
}
I have checked all my modules, none of them expect for module1.js are calling module2.js.
I have also explored the option of webpack comments being deleted by babel and therefore added a comments: true to make sure the webpackChunkName is not being deleted but in the end, the only thing that gets built is my lib.js, not the lib.bundle.js that I expect.
I have also tried to remove all the TerserPlugin bit to check if that could have the same impact but nothing changed there.
In the need, what I am looking for is simply to have the module2.js loaded whenever it is invoked, and I therefore expect a new network request to materialise this.
Well, it turns out that if you want to use dynamic imports you need to make sure first that you are not importing at all the module at the top....
In module1.js I was importing twice, once at the top, the "regular way", once the dynamic way which was obviously leading to module2.js being consistently loaded.
I resolve my problem by modify .babelrc, modules: false
["#babel/preset-env", {
"loose": true,
"useBuiltIns": "usage",
"corejs": 3,
"modules": false
}],

googleapi: got HTTP response code 404 with body: Not Found

I have this problem when I try to use the library for Golang "libretto" to instance VM from script
vm := &gcp.VM{
Name: "test-vm-2",
Zone: "us-central1-f",
MachineType: "n1-standard-1",
SourceImage: "centos-7-v20181011",
Disks: []gcp.Disk{
{
DiskType: "pd-standard",
DiskSizeGb: 10,
AutoDelete: true,
},
},
Preemptible: false,
Network: "default",
Subnetwork: "default",
UseInternalIP: false,
Project: os.Getenv(accountFile.ProjectID),
Scopes: []string {
"https://www.googleapis.com/auth/devstorage.read_write",
"https://www.googleapis.com/auth/logging.write",
},
AccountFile: "key.json",
SSHCreds: ssh.Credentials {
SSHUser: "VinCur",
SSHPrivateKey: accountFile.PrivateKey,
},
SSHPublicKey: pub_ssh,
}
This is the code...some solution?

Browserstack multiple browser does not run for protractor

I am trying to run multiple browsers in parallel using browser stack but it does not seem possible with it. This is is my config file
exports.config = {
capabilities: {
'browserstack.user' : 'abc2',
'browserstack.key' : 'asdasdasdasdj',
// Needed for testing localhost
'browserstack.local' : 'false',
multiCapabilities: [
{
browserName: 'Safari',
browser_version: '8.0',
os: 'OS X',
os_version: 'Yosemite'
},
{
browserName: 'Firefox',
browser_version: '30.0',
os: 'Windows',
os_version: '7'
},
{
browserName: 'iPhone',
platform: 'MAC',
device: 'iPhone 5S'
}
]
},
When i run - npm run protractor, i get this error Target browser must be a string, but is ; did you forget to call forBrowser()?
You need to specify browserName capability under capabilities block. Below is a working sample
exports.config = {
'specs': [ '../specs/single.js' ],
'seleniumAddress': 'http://hub-cloud.browserstack.com/wd/hub',
'commonCapabilities': {
'browserstack.user': process.env.BROWSERSTACK_USERNAME || 'BROWSERSTACK_USERNAME',
'browserstack.key': process.env.BROWSERSTACK_ACCESS_KEY || 'BROWSERSTACK_ACCESS_KEY',
'build': 'protractor-browserstack',
'name': 'parallel_test',
'browserstack.debug': 'true',
'browserName': 'Chrome'
},
'multiCapabilities': [{
'browserName': 'Chrome'
},{
'browserName': 'Safari'
},{
'browserName': 'Firefox'
},{
'browserName': 'IE'
}]
};
// Code to support common capabilities
exports.config.multiCapabilities.forEach(function(caps){
for(var i in exports.config.commonCapabilities) caps[i] = caps[i] || exports.config.commonCapabilities[i];
});
The 'browserName': 'Chrome' capability will later be overriden by your multiCapabilities block.

Angular 2 karma unit tests, template error

I've got a problem - when I try to configure testbed, it throws error
Failed: Uncaught (in promise): Failed to load /student-register.component.html
I tried to solve this problem by overriding the component and setting empty template, but I'll need to test integration with html too, I tried also to override component by changing setting templateUrl, but I tried every possibility, and it throws failed to load error.
Also I tried to override using require
template: require('./student-register.component.html')
but it thrown me 1000 errors about angular's ngmodels etc, I want to avoid using require then.
It's my spec file:
describe('Component: Student Register Component', () => {
let component: StudentRegisterComponent;
let fixture: ComponentFixture<StudentRegisterComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
HttpModule,
],
providers: [
{ provide: 'ApiBaseUrl', useValue: 'localhost'},
AuthenticationGuard,
AuthService,
DatePipe,
FormBuilder,
MockPictureUpload,
{ provide: ActivatedRoute, useValue: {} },
{ provide: ApiService, useClass: MockApiService},
{ provide: PictureUploadComponent, useClass: MockPictureUpload},
{ provide: Router, useValue: mockRouter }
],
declarations: [StudentRegisterComponent, MockPictureUpload],
})
.overrideComponent(StudentRegisterComponent, {
set: {
providers: [
MockPictureUpload,
{ provide: ApiService, useClass: MockApiService},
{ provide: PictureUploadComponent, useClass: MockPictureUpload},
],
// template: require('./student-register.component.html')
// templateUrl: './student-register.html'
// template: ``
}
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(StudentRegisterComponent);
component = fixture.componentInstance;
});
}
There is my karma.conf.js:
module.exports = function(config) {
var testWebpackConfig = require('./webpack.test.js')({env: 'test'});
var configuration = {
// base path that will be used to resolve all patterns (e.g. files, exclude)
basePath: '',
/*
* Frameworks to use
*
* available frameworks: https://npmjs.org/browse/keyword/karma-adapter
*/
frameworks: ['jasmine'],
// list of files to exclude
exclude: [ ],
/*
* list of files / patterns to load in the browser
*
* we are building the test environment in ./spec-bundle.js
*/
files: [ { pattern: './config/spec-bundle.js', watched: false } ],
/*
* preprocess matching files before serving them to the browser
* available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
*/
preprocessors: { './config/spec-bundle.js': ['coverage', 'webpack', 'sourcemap'] },
// Webpack Config at ./webpack.test.js
webpack: testWebpackConfig,
hostname: '127.0.0.1',
coverageReporter: {
type: 'in-memory'
},
remapCoverageReporter: {
'text-summary': null,
json: './coverage/coverage.json',
html: './coverage/html'
},
// Webpack please don't spam the console when running in karma!
webpackMiddleware: { stats: 'errors-only'},
/*
* test results reporter to use
*
* possible values: 'dots', 'progress'
* available reporters: https://npmjs.org/browse/keyword/karma-reporter
*/
reporters: [ 'mocha', 'coverage', 'remap-coverage' ],
// web server port
port: 9876,
hostname: '127.0.0.1',
// enable / disable colors in the output (reporters and logs)
colors: true,
DEFAULT_TIMEOUT_INTERVAL: 5000,
/*
* level of logging
* possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
*/
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: false,
/*
* start these browsers
* available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
*/
browsers: [
'PhantomJS'
],
customLaunchers: {
ChromeTravisCi: {
base: 'Chrome',
flags: ['--no-sandbox']
}
},
/*
* Continuous Integration mode
* if true, Karma captures browsers, runs the tests and exits
*/
singleRun: true
};
if (process.env.TRAVIS){
configuration.browsers = [
'ChromeTravisCi'
];
}
config.set(configuration);
};
And tsconfig.json:
{
"strictNullChecks": false,
"compilerOptions": {
"baseUrl": "",
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"noEmit": true,
"noEmitHelpers": false,
"outDir": "",
"types": [
"hammerjs",
"jasmine",
"node",
"selenium-webdriver",
"source-map",
"uglify-js",
"webpack"
],
"paths": {
},
"lib": [
"dom",
"es6"
]
},
"exclude": [
"node_modules",
"dist",
"**/*.spec.ts"
],
"awesomeTypescriptLoaderOptions": {
"forkChecker": true,
"useWebpackText": true
},
"compileOnSave": false,
"buildOnSave": false,
"atom": { "rewriteTsconfig": false },
"typeRoots": [
"node_modules/#types"
]
}
Thanks :)

Protractor running some tests in parallel and some tests sequentially

I have a situation where I want to run some protractor tests in parallel in order to save time taken to run the tests. The difficulty I have is that some of these tests can't be run in parallel as the results in 1 browser are affecting the expected results in another session.
Is it possible to set my protractor config file in order to be able to do this? My current setup is shown below but this isn't working:
multiCapabilities: [
//tests run sequentially
{'browserName': 'firefox', specs: ['e2e/DynamicUpdates/**/*.spec.js'], maxInstances: 1, exclude: ['e2e/main/**/*.spec.js']},
{'browserName': 'chrome', specs: ['e2e/DynamicUpdates/**/*.spec.js'], maxInstances: 1, exclude: ['e2e/main/**/*.spec.js']},
{'browserName': 'internet explorer', specs: ['e2e/DynamicUpdates/**/*.spec.js'], maxInstances: 1, exclude: ['e2e/main/**/*.spec.js']},
{'browserName': 'safari', specs: ['e2e/DynamicUpdates/**/*.spec.js'], maxInstances: 1, exclude: ['e2e/main/**/*.spec.js']},
// Main tests - run in parallel
{'browserName': 'chrome', 'chromeOptions': {args: ['--start-maximized']}, shardTestFiles: true, maxInstances: 3},
{'browserName': 'firefox', shardTestFiles: true, maxInstances: 3},
{'browserName': 'safari', shardTestFiles: true, maxInstances: 3},
{
'browserName': 'internet explorer',
'binary': 'C:/Program Files (x86)/Internet Explorer/iexplore.exe',
'ensureCleanSession': true,
'nativeEvents': false,
'ignoreProtectedModeSettings': true,
'disable-popup-blocking': true,
'enablePersistentHover': true,
shardTestFiles: true,
maxInstances: 3
},
// Performance tests (currently not run against IE due to webdriver issues)
{'browserName': 'chrome', specs: ['/**/*.spec.js'] },
{'browserName': 'firefox', specs: ['/**/*.spec.js'] },
],
maxSessions: 3,
In the specs array, type out the files in order that you want them to run in. Or keep it the way it is and change the names of the files so they run in the proper sequence.
{'browserName': 'firefox',
specs: ['e2e/DynamicUpdates/folder1/testA.spec.js', 'e2e/DynamicUpdates/folder1/testB.spec.js', 'e2e/DynamicUpdates/folder1/testC.spec.js'],
maxInstances: 1, exclude: ['e2e/main/**/*.spec.js']},