These are chat archives for canjs/canjs

23rd
Nov 2017
Viktor Busko
@Lighttree
Nov 23 2017 09:28

@bmomberger-bitovi yeah testee is easier way, but it will use Phantom on CI as far as I know and this is something that I would like to avoid. My expectation is that running test directly in Node should be faster (for this purpose), because you won't run headless browser etc.

Besides I was able to run it with JSDom :) If someone interested.

Added some extra config for Mocha:
"test": "mocha --require babel-core/register config/tests src/**/*.test.js"

config itself:

import { JSDOM } from 'jsdom';
import requireHacker from 'require-hacker';

const { document } = (new JSDOM('...')).window;

// Mock unnescessary modules.
requireHacker.hook('stache', () => 'module.exports = ""');
requireHacker.hook('scss', () => 'module.exports = ""');

// Emulate browser API.
Object.keys(document.defaultView).forEach((property) => {
    if (typeof global[property] === 'undefined') {
        global[property] = document.defaultView[property];
    }
});

During this work I was able to reproduce this issue :
canjs/can-make-rest#12

I have workaround for this issue in my webpack config for a long time. (just added an alias):

resolve: {
        alias: {
            'can-make-rest': 'can-make-rest/can-make-rest'
        }
 }

But since mocha runs without webpack build this issue strikes back :)

Brad Momberger
@bmomberger-bitovi
Nov 23 2017 16:26
@Lighttree we have CI and we use Firefox. Like, real Firefox. No need for a headless build. We just set up Xvfb to receive the graphical bits and it's fine. You can see this in any .travis.yml file in https://github.com/canjs/can-define/blob/master/.travis.yml
Is is as fast as running without a headless browser? No. You still have some overhead for spawning the browser. But it's less of a hassle to set up, and it's tried and tested. We know it works well.
Are you using can-make-rest 0.1.2 or later and still seeing that issue?