petehunt / generator-react-library

Yeoman generator for React components
Apache License 2.0
17 stars 5 forks source link

Auto run `npm init` or not #3

Closed chenglou closed 10 years ago

chenglou commented 10 years ago

The only real reason why the tests are failing is because npm init is run right after the generator's other works, prompting for input. After two seconds the test times out and fails.

@petehunt I'm wondering if there's a way to send random enter keys to the terminal to step through package.json's creation programmatically.

petehunt commented 10 years ago

https://github.com/nodejitsu/nexpect

chenglou commented 10 years ago

Tried it for a whole day, the module's incredibly buggy and not really well maintained imo. Here's the result:

  1. Tried spawning mocha (with PR #4), then wait for lines and send lines. This is the only working option, except it errors twice out of three for mysterious reasons. Also, even if this works 100% it's not optimal as the module swallows the output and you have no idea what happens afterward beside checking some output files.
  2. Went back to manually spawning mocha, which in turn runs the two test files. In test-creation.js, I spawn a node createTestFolder.js (in which there's the current helpers.testDirectory(...) script). This procedure fails to send line to stdin.
  3. Tried a similar procedure by just invoking yo react-library; now it hangs.

I'll submit a new commit in that PR. The index.js file corresponds to 1; the rest, 2. 3 Isn't included. Getting really weird so for now I'll leave this issue be.