wallabyjs / public

Repository for Wallaby.js questions and issues
http://wallabyjs.com
759 stars 45 forks source link

Support rerunning tests when non-js files loaded from the tests via fs.readFile change #1322

Open lgandecki opened 7 years ago

lgandecki commented 7 years ago

Issue description or question

I use a templating system in which I do:

const template = fs.readFileSync('./template.html')

and then parse it.

The first time I started up wallabyjs I was in awe to discover, that changing the html template would affect the tests in real-time. Pairing it up with jest snapshots is fantastic. Unfortunately, after restarting wallabyjs it no longer works. When I make a change in the test related to that file, it starts working, until restart (frequently the first restart still works, but the next and consequential ones are not).

I'm attaching the repro. http://github.com/lgandecki/blazeRenderer

The html files are in imports/client/lib . Try changing imports/client/lib/nestedTemplateWithParameters.html . for test use the tests/template.test.js

and the recording http://recordit.co/zwBgQKusIr

Is there something you can do? Jest itself seems to ignore the changes, so I think this is wallabyjs related.

Wallaby.js configuration file

module.exports = function (wallaby) { return { files: [ 'renderBlaze//.js', '.js', 'tests//*.js',

        '*.json',
        '*.html',
        'tests/**/*.html',
        'imports/**/*.html',
        { pattern: 'tests/**/*.test.js', ignore: true }
    ],

    tests: [
        'tests/**/*.test.js',
    ],

    compilers: {
        '**/*.js': wallaby.compilers.babel()
    },

    env: {
        type: 'node'
    },
    testFramework: 'jest'
}

};

Code editor or IDE name and version

WebStorm

OS name and version

OSX

ArtemGovorov commented 7 years ago

Jest itself seems to ignore the changes, so I think this is wallabyjs related.

Correct, Jest simply doesn't support it, and wallaby doesn't support it either. Tracking file dependencies based on anything else than node's require module loading mechanism is tricky.

Wallaby just has some builtin smarts, so that when it can't figure out what tests to run as a result of a file change (.html in your case), it re-runs the last edited spec. So if you want it to work in wallaby, then after a restart, touch a related spec file, then start editing html files - this way it should work.