Skip to content

Instantly share code, notes, and snippets.

1. Run jest with worker count higher than 1. Empty test that just sleeps for a minute will do.
2. Kill one of the workers intentionally. In practice, they may die for whatever reason, for us we suspect it is OOM.
3. Jest will indefinitely hang.
Related and recent fix https://github.com/facebook/jest/pull/13054/files#diff-e99351d361fdd6f55d39c7c41af94576baccc2b9dce73a5bfd0b516c6ab648e9
However the workers may crash with other signals and those scenarios are not covered. In our case, after some debugging, the signal is null. For some reason these workers are crashing in jest-runtime at the compileFunction.call line, and causes a null exit code, which gets ignored. jest-runner waits on a thread pool that'll never fulfil the submitted job.
The signal appears to be SIGKILL instead of SIBABRT , and the exitCode appears to be null. Please see screenshots of the debug process.
@vilmosioo
vilmosioo / directive.js
Last active August 29, 2015 14:12
ngIf in Angular 1.3
'use strict';
angular.module('myApp', [])
.directive('myDirective', function(){
return {
restrict: 'E',
template: '<div ng-if="isVisible"></div>',
scope: true,
controller: function(){
$scope.isVisible = false;
angular.module('app', [])
.directive('myAwsomeDirective', function($rootScope) {
return {
restrict: 'A',
link: function(scope) {
// $scope.$on() returns an unbind function of the binding
//
// So use the bind function directly within scope's $destroy event
// to unbind event automatically.
scope.$on('$destroy', $rootScope.$on('my:event', function() {
@vilmosioo
vilmosioo / onPrepare.js
Created July 3, 2014 13:09
Protractor screenshots
var fs = require('fs'),
path = require('path');
afterEach(function(){
var passed = jasmine.getEnv().currentSpec.results().passed();
// Replace all space characters in spec name with dashes
var specName = jasmine.getEnv().currentSpec.description.replace(/ /g, '-'),
baseFileName = specName,
screenshotsDir = path.resolve(__dirname + '../screenshots/');
exports.config = {
// ----- What tests to run -----
specs: [
'test/e2e/*.js'
],
// ----- Capabilities to be passed to the webdriver instance ----
capabilities: {}, // not required anymore
@vilmosioo
vilmosioo / new.js
Created June 18, 2014 15:38
Protractor Promise
// create a rejected promise
return protractor.promise.rejected();
// create a resolved promise
return protractor.promise.fulfilled();
@vilmosioo
vilmosioo / branch.sh
Created June 9, 2014 09:00
List of commits to handle local and remote branches
// create local branches that target remote branches
for branch in `git branch -a | grep remotes | grep -v HEAD | grep -v master `; do
git branch --track ${branch#remotes/origin/} $branch
done
// delete all remote branches that have been merged to master
git branch --merged master | grep -v master | xargs -n 1 git push --delete origin
// delete all local branches that have been merged to master
@vilmosioo
vilmosioo / app.js
Last active January 3, 2016 16:49
Loading component during route resolve phase
$routeProvider
.when('/about-us', {
title: 'About Us',
templateUrl: 'views/about_us_view.html',
controller: 'AboutUs_controller',
resolve: {
resolvedData: function($q, $timeout){
// create a promise that only gets resolved when all components are loaded
var defer = $q.defer();
// Load and execute scripts. You can use any script loader you prefer. In this example I use $LAB
@vilmosioo
vilmosioo / app.js
Last active January 3, 2016 16:49
Change component registration during configuration phase.
// Initialize your angular app module
angular.module('ngApp', [/* any other dependet modules */])
// our configuration method
.config(function($controllerProvider, $compileProvider, $filterProvider, $provide){
// Save old component registration methods (optional).
angular.module('ngApp')._controller = angular.module('ngApp').controller;
@vilmosioo
vilmosioo / controller.js
Created January 18, 2014 14:46
Registering a controller in angular.
// How to register a controller normally
angular.module('ngApp').controller(/*controller code*/);
// How to register a controller after application bootstrap
$controllerProvider.register(/*controller code*/);