Nerajno / gulp-jest

Gulp plugin for the Jest test lib
MIT License
53 stars 43 forks source link

gulp-jest running the same test file for each other test file #39

Closed RSeidelsohn closed 7 years ago

RSeidelsohn commented 7 years ago

I have a gulp watch task watching for file changes in the test file directory. Test file updates are detected correctly. Then a test task is run that pipes the changes file through to gulp-jest, but gulp-jest always runs the same test file again an again - once for each test file in the test directory.

const gjest  = require('gulp-jest').default;
const debug = require('gulp-debug');

module.exports = function(gulp, config) {
    return function() {
        return gulp
            .src(config.srcPath + 'scripts/tests/*.test.js')
            .pipe(debug())
            .pipe(gjest({
                'config': {
                    'transformIgnorePatterns': [
                        '<rootDir>/bin/',
                        '<rootDir>/capistrano/',
                        '<rootDir>/config/',
                        '<rootDir>/coverage/',
                        '<rootDir>/src/',
                        '<rootDir>/web/',
                        '<rootDir>/node_modules/',
                    ],
                    'automock': false,
                    'notify': true,
                },
            }));
    };
};

The irritating output after I change one test file is this (note the debug output showing the file names of all the test files in my test file directory):

[16:39:40] Starting 'eslint'...
[16:39:40] File /home/roman/Development/project-ongr/app/Resources/scripts/tests/templates-helper.test.js was changed, keep watching ...
[16:39:42] Finished 'eslint' after 1.69 s
[16:39:42] Starting 'test-scripts'...
[16:39:42] gulp-debug: app/Resources/scripts/tests/price-formatting.test.js
[16:39:42] gulp-debug: app/Resources/scripts/tests/templates-helper.test.js
 PASS  app/Resources/scripts/tests/price-formatting.test.js
  priceFormatting
    ✓ formatPrice returns a correctly formatted price (4ms)
    ✓ formatPriceValue returns a correctly formatted price value (1ms)
    ✓ formatPricesIn fills price containers with formatted prices using their unformatted-price data attributes (16ms)
    ✓ exposePriceFormatting exposes the price formatting functions to the global project object (1ms)

Test Suites: 1 passed, 1 total
Tests:       4 passed, 4 total
Snapshots:   0 total
Time:        0.547s, estimated 1s
Ran all test suites.
 PASS  app/Resources/scripts/tests/price-formatting.test.js
  priceFormatting
    ✓ formatPrice returns a correctly formatted price (1ms)
    ✓ formatPriceValue returns a correctly formatted price value (1ms)
    ✓ formatPricesIn fills price containers with formatted prices using their unformatted-price data attributes (2ms)
    ✓ exposePriceFormatting exposes the price formatting functions to the global project object (1ms)

Test Suites: 1 passed, 1 total
Tests:       4 passed, 4 total
Snapshots:   0 total
Time:        0.088s, estimated 1s
Ran all test suites.
[16:39:42] gulp-debug: app/Resources/scripts/tests/utils.test.js
[16:39:42] gulp-debug: 3 items
 PASS  app/Resources/scripts/tests/price-formatting.test.js
  priceFormatting
    ✓ formatPrice returns a correctly formatted price (2ms)
    ✓ formatPriceValue returns a correctly formatted price value (1ms)
    ✓ formatPricesIn fills price containers with formatted prices using their unformatted-price data attributes (2ms)
    ✓ exposePriceFormatting exposes the price formatting functions to the global project object (1ms)

Test Suites: 1 passed, 1 total
Tests:       4 passed, 4 total
Snapshots:   0 total
Time:        0.087s, estimated 1s
Ran all test suites.
[16:39:42] Finished 'test-scripts' after 807 ms

This looks like a gulp-jest related error to me.

RSeidelsohn commented 7 years ago

Sorry, I now figured out that this only happens when I only save the test file without any real code change. If I change the test code, everything runs as expected. My bad!