slushjs / gulp-conflict

Check if files in stream conflict with those in target dir, with option to use new, keep old, show diff, etc.
MIT License
22 stars 12 forks source link

Conflict module, causing tests to time out. #6

Open the-simian opened 9 years ago

the-simian commented 9 years ago

I am also using the mock-gulp-test module. In situations when you are scaffolding files that are also the names of files in the scaffolding tool, like README.md and package.json, the confilct module prompts and interrupts the test, causing it to fail.

with conflict in the pipeline

[?] Replace README.md? (Ynaxdh)  0

  0 passing (2s)
  1 failing

  1) slush-example default should make a readme:
     Error: timeout of 2000ms exceeded. Ensure the done() callback is being called in this test.
      at null.<anonymous> (E:\Users\<username>\Desktop\slush-example\node_modules\mocha\lib\runnable.js:170:19)
      at Timer.listOnTimeout [as ontimeout] (timers.js:112:15)

stream.js:94
      throw er; // Unhandled stream error in pipe.
            ^
Error: 1 test failed.

when I take it out everything is ok. This is only occuring on the unit tests, is there a way around this? I've tried doing something similar to what you are doing in this

but the prompts are still causing issues.

I would also add that the .on('stop') did not work in my tests, and I had to resort to using on('task_stop'). If this is the wrong module to be submitting this issue let me know.

I haven't gone into exhaustive detail in case this is something you've encountered before. However, if you'd like more detail, let me know and I can flesh it out more throughout. Thank you very much for your hard work on this module and your time.

aendra-rininsland commented 7 years ago

I'm also experiencing this and it's preventing me from getting any tests whatsoever to work. I'll be fighting against this all day and might submit a PR if I'm able to figure out why it's doing this.

aendra-rininsland commented 7 years ago

Update: Seems this line enables the prompt to be skipped if NODE_ENV is set to "test". However, this doesn't seem to have any effect at all; the prompt remains.

the-simian commented 7 years ago

@aendrew I ended up mocking the prompt fully https://github.com/the-simian/slush-phaser-webpack/blob/master/test/state/task.js https://github.com/the-simian/slush-phaser-webpack/blob/master/test/inquirer-prompt-fixture.js

aendra-rininsland commented 7 years ago

@the-simian My solution was to set the target directory to /tmp:

const isTesting = process.env.NODE_ENV === 'test';
gulp.src(__dirname + '/templates/**')
.pipe(conflict(isTesting ? '/tmp' : './'))
.pipe(gulp.dest('./'));