How to use karma - 10 common examples

To help you get started, we’ve selected a few karma examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github keymanapp / keyman / web / testing / regression-tests / test-builder.js View on Github external
}
});

fs.writeFileSync('./tests-generated.js', code);

//
// Run Karma with the generated tests
//

const Server = require('karma').Server;
const cfg = require('karma').config;

// Note: if karma.conf.js is invalid, then this will die with exit code 1
// without logging the error. The easiest way to see the error is to
// run `node_modules/bin/karma start karma.conf.js`
const karmaConfig = cfg.parseConfig(path.resolve('./karma.conf.js'), process.env.TEAMCITY_PROJECT_NAME ? {'reporters': ['teamcity']} : {});

let server = new Server(karmaConfig, function(exitCode) {
  console.log('Karma has exited with ' + exitCode)
  process.exit(exitCode)
});

server.start();
github c-zhuo / easycanvas / test / cases / feature.add.js View on Github external
it('Default value correctly.', function (done) {
        setTimeout(() => {
            let children = $Painter.children;
            expect(children.length).toBe(1);
            expect(children[0].style.left).toBe(0);
            expect(children[0].style.top).toBe(77);
            expect(children[0].style.opacity).toBe(1);
            expect(children[0].style.rotate).toBe(undefined);
            expect(children[0].style.zIndex).toBe(0);
            expect(children[0].events.eIndex).toBe(undefined);
            // expect(children[0].inherit.indexOf('tx') >= 0).toBe(true);
            expect(children[0].content.img.width).toBe(10);
            done();
        }, constants.waitForUpdateTime);
    });
github dsebastien / modernWebDevBuild / gulp / tasks / test-unit.js View on Github external
gulp.task("test-unit-dev", "Execute all unit tests continuously (watches files)", (callback) =>{
    return new KarmaServer({
        configFile: karmaConfigFilePath, // necessary otherwise the file is not resolved correctly
        singleRun: false
    }, callback).start();
});
github SUI-Components / sui / packages / sui-test / bin / karma / index.js View on Github external
let resolve, reject

  // eslint-disable-next-line
  let promise = new Promise((res, rej) => {
    resolve = res
    reject = rej
  })

  let callback = code => {
    if (code === 0) return resolve()
    let err = Error(`Exit ${code}`)
    err.code = code
    reject(err)
  }

  let server = new Server(config, callback)

  server.completion = promise
  return server
}
github c-zhuo / easycanvas / test / cases / feature.perf-jumpRenderOfCoveredSprite.js View on Github external
});
            }

            // 校验每组元素,真正绘制了几个
            var jumps = [];
            [1,2,3,4,5].forEach((n) => {
                jumps.push(sprites['type' + n].filter((bool) => {
                    return bool;
                }).length);
            });

            // 加载慢的话会报5个0
            expect(jumps.join(',')).toBe('0,4,7,0,0');

            done();
        }, constants.waitForUpdateTime + 100);
    });
});
github c-zhuo / easycanvas / test / cases / feature.sequence.jsx View on Github external
// 'createEvent' not working as expected
            // var evt = document.createEvent('MouseEvents');
            // evt.initMouseEvent('click', true, true, window, 1, 0, 0, 222, 222, false, false, false, false, 0, null);
            // $Painter.$dom.dispatchEvent(evt);

            // 这个case有时候是0,有时候$children是undefined
            // 可能是图片还没加载完,报错了重新跑试试(按理说本地图片不会这么慢?)
            expect($Painter.$children.length).toBe(1);

            expect($Painter.$children[0].type).toBe('img');
            expect($Painter.$children[0].props.cutWidth).toBe(Math.round(Fire.width / 9));
            expect($Painter.$children[0].props.cutHeight).toBe(Math.round(Fire.height));
            expect($Painter.$children[0].props.left).toBe(Math.round(posX - Fire.width / 9 / 2));
            expect($Painter.$children[0].props.top).toBe(Math.round(posY - Fire.height / 2));
            done();
        }, constants.waitForUpdateTime * 2);
    });
});
github c-zhuo / easycanvas / test / cases / feature.scale.js View on Github external
expect(getRenderTStyle($Painter.$children[1].props)).toBe('540,40,150,150');

            // tx/ty 100~130  ==>  85~145
            expect(getRenderTStyle($Painter.$children[2].props)).toBe('-35,65,300,300');
            // render逻辑调整,
            // expect(getRenderTStyle($Painter.$children[2].props)).toBe('0,65,265,300');

            // 如果没有scale,结果为'140,140,150,150',中心(215,215)
            // scale 5 ==> size 750, 215 - 375 = -160
            // 结果 -160,-160,750,750 ==> 0,0,590,590
            expect(getRenderStyle($Painter.$children[3].props)).toBe('0,0,30,30,540,540,150,150');
            expect(getRenderStyle($Painter.$children[4].props)).toBe('0,0,30,30,-160,-160,750,750');
            // render逻辑调整,
            // expect(getRenderStyle($Painter.$children[4].props)).toBe('6.4,6.4,23.6,23.6,0,0,590,590');
            done();
        }, constants.waitForUpdateTime);
    });
});
github c-zhuo / easycanvas / test / cases / feature.scale.js View on Github external
import Easycanvas from 'src/index.js';
import constants from 'karma/case.constant.js';

var $canvas = document.createElement('canvas');
$canvas.width = 888;
$canvas.height = 888;
document.body.appendChild($canvas);

var $Painter = new Easycanvas.Painter();
$Painter.register($canvas);
$Painter.start();

var sprite1;

Easycanvas.ImgLoader(constants.png30px, function (img) {
    sprite1 = $Painter.add({
        // $children[0]
        content: {
            img: img,
        },
        style: {
            left: 100, top: 100,
            width: 30, height: 30,
            locate: 'lt',
            scale: 5, // scale中心为115, 115
        },
        children: [
            {
                // $children[1]
                content: {
                    img: img,
github c-zhuo / easycanvas / test / cases / feature.perf-jumpRenderOfCoveredSprite.js View on Github external
Easycanvas.ImgLoader(constants.png30px, function (img) {
    // 跳过绘制0个
    sprites.type5 = [];
    for (var i = 0; i < 32; i++) {
        var sprite = $Painter.add({
            content: {
                img: i % 2 ? img : constants.png30px,
            },
            style: {
                left: 200, top: 200,
                width: 200, height: 300,
                zIndex: 5,
            },
        });
        sprites.type5.push(sprite);
    }
});
github c-zhuo / easycanvas / test / cases / feature.perf-jumpRenderOfCoveredSprite.js View on Github external
content: {
                img: i % 2 ? img : constants.jpg100px,
            },
            style: {
                left: 200, top: 200,
                width: 200, height: 300,
                opacity: 0.6,
                zIndex: 4,
            },
        });
        sprites.type4.push(sprite);
    }
});

Easycanvas.ImgLoader.cacheCanvas = false;
Easycanvas.ImgLoader(constants.png30px, function (img) {
    // 跳过绘制0个
    sprites.type5 = [];
    for (var i = 0; i < 32; i++) {
        var sprite = $Painter.add({
            content: {
                img: i % 2 ? img : constants.png30px,
            },
            style: {
                left: 200, top: 200,
                width: 200, height: 300,
                zIndex: 5,
            },
        });
        sprites.type5.push(sprite);
    }
});