Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npm run test just hangs on jest w/o any feedback #157

Closed
matthewharwood opened this issue Mar 16, 2018 · 15 comments
Closed

npm run test just hangs on jest w/o any feedback #157

matthewharwood opened this issue Mar 16, 2018 · 15 comments

Comments

@matthewharwood
Copy link

matthewharwood commented Mar 16, 2018

Not really sure what's breaking in my case but when I run what I would think are passing test the command line gives zero feedback

On the hello-world untouched I get errors like:

 xtypescript@1.0.0 test /Users/matty/exercism/typescript/hello-world
 tsc --noEmit -p . && jest --no-cache

hello-world.test.ts(11,12): error TS2554: Expected 0 arguments, but got 1.
hello-world.test.ts(15,12): error TS2554: Expected 0 arguments, but got 1.

But lines 11, 15 are xit and therefore shouldn't be called.

If I delete them or satisfy the tests than the command line gives me no feedback

Or if I complete the tests I get no feedback:

class HelloWorld {
    static hello( name='World' ) {
        return `Hello, ${name}!`
    }
}

export default HelloWorld

^ should satisfy all the test but when running npm run test

The terminal just hangs

> xtypescript@1.0.0 test /Users/matty/exercism/typescript/hello-world
> tsc --noEmit -p . && jest --no-cache

nothing more... any help?

@masters3d
Copy link
Contributor

What global version of TS and node?

Have you tried yarn?

@CRivasGomez
Copy link
Contributor

Hi @matthewharwood !

Even when you tag your test cases with xit they will be examined by the TypeScript transpiler to find errors.

After fixing those tests, as @masters3d says, I would recommend you to run yarn test inside hello-world folder after running yarn install (instead of npm test)

If it doesn't work for you, let us know 👍

@matthewharwood
Copy link
Author

Still failing on my properly hello-world.ts. I uninstalled node_modules and deleted .locks files then yarn installed then yarn test and it hangs still.

tsc -v
Version 2.7.2

node -v
v9.4.0

yarn -v
1.5.1

You mentioned to list my node version so...
I also tried to downgrade to node LTS v8.10.0. On a new hello-world project I ran

  • npm install -g typescript && yarn
  • cd into hello-world
  • yarn
  • yarn test
$ tsc --noEmit -p . && jest --no-cache
hello-world.test.ts(11,12): error TS2554: Expected 0 arguments, but got 1.
hello-world.test.ts(15,12): error TS2554: Expected 0 arguments, but got 1.
error An unexpected error occurred: "Command failed.
Exit code: 1
Command: sh
Arguments: -c tsc --noEmit -p . && jest --no-cache
Directory: /Users/matty/exercism/typescript/hello-world
Output:
".
info If you think this is a bug, please open a bug report with the information provided in "/Users/matty/exercism/typescript/hello-world/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Here's an abridged log:

Arguments: 
  /Users/matty/.nvm/versions/node/v8.10.0/bin/node /Users/matty/.nvm/versions/node/v8.10.0/bin/yarn test

PATH: 
  /Users/matty/.nvm/versions/node/v8.10.0/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

Yarn version: 
  1.5.1

Node version: 
  8.10.0

Platform: 
  darwin x64
  
Trace: 
  Error: Command failed.
  Exit code: 1
  Command: sh
  Arguments: -c tsc --noEmit -p . && jest --no-cache
  Directory: /Users/matty/exercism/typescript/hello-world
  Output:
  
      at ProcessTermError.MessageError (/Users/matty/.nvm/versions/node/v8.10.0/lib/node_modules/yarn/lib/cli.js:186:110)
      at new ProcessTermError (/Users/matty/.nvm/versions/node/v8.10.0/lib/node_modules/yarn/lib/cli.js:226:113)
      at ChildProcess.<anonymous> (/Users/matty/.nvm/versions/node/v8.10.0/lib/node_modules/yarn/lib/cli.js:30281:17)
      at emitTwo (events.js:126:13)
      at ChildProcess.emit (events.js:214:7)
      at maybeClose (internal/child_process.js:925:16)
      at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)

Then I fix the code for the tests

class HelloWorld {
    static hello( name = 'World' ) {
        return `Hello ${name}!`
    }
}

export default HelloWorld

I leave the tests cases the same and/or remove the x from xit:


import HelloWorld from "./hello-world"

describe('Hello World', () => {

  it('says hello world with no name', () => {
    expect(HelloWorld.hello()).toEqual('Hello, World!')
  })

  xit('says hello to bob', () => {
    expect(HelloWorld.hello('Bob')).toEqual('Hello, Bob!')
  })

  xit('says hello to sally', () => {
    expect(HelloWorld.hello('Sally')).toEqual('Hello, Sally!')
  })
})

and no feedback after

$ yarn test
yarn run v1.5.1
$ tsc --noEmit -p . && jest --no-cache

just seems to pause there.

@masters3d
Copy link
Contributor

what does yarn install say?

@masters3d
Copy link
Contributor

can you try reinstalling typescript?
#124

@matthewharwood
Copy link
Author

matthewharwood commented Mar 16, 2018

Per @vermiculus comment in #124 I ran:

rm -rf ~/exercism/typescript # your exercism directory
npm uninstall -g typescript && npm uninstall -g yarn # if originally installed via npm
rm -rf ~/node_modules/ # remove node modules
brew install typescript yarn
exercism fetch typescript
cd ~/exercism/typescript/hello_world/ # or wherever exercism places the directory

From there I cd ~/exercism/typescript/hello-world.
The following should be the yarn install output you asked for:

matty@laptop: ~/exercism/typescript/hello-world
$ yarn install && yarn test
yarn install v1.5.1
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 📃  Building fresh packages...
✨  Done in 3.41s.
yarn run v1.5.1

$ tsc --noEmit -p . && jest --no-cache
hello-world.test.ts(11,12): error TS2554: Expected 0 arguments, but got 1.
hello-world.test.ts(15,12): error TS2554: Expected 0 arguments, but got 1.
error An unexpected error occurred: "Command failed.
Exit code: 1
Command: sh
Arguments: -c tsc --noEmit -p . && jest --no-cache
Directory: /Users/matty/exercism/typescript/hello-world
Output:
".
info If you think this is a bug, please open a bug report with the information provided in "/Users/matty/exercism/typescript/hello-world/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
matty@laptop: ~/exercism/typescript/hello-world

I fixed the code for the tests again:

class HelloWorld {
    static hello( name = 'World' ) {
        return `Hello ${name}!`
    }
}

export default HelloWorld

Ran same command:

$ yarn install && yarn test
yarn install v1.5.1
[1/4] 🔍  Resolving packages...
success Already up-to-date.
✨  Done in 0.32s.
yarn run v1.5.1
$ tsc --noEmit -p . && jest --no-cache

Still justs hangs here after the yarn test.

Small update that tsc --noEmit -p . runs and completes. jest --no-cache is what seemingly breaks

@masters3d
Copy link
Contributor

okay. This may be a mac issue with the new version of ts.

@CRivasGomez Do you happen to have a mac to test this? I am on a windows machine this weekend.

@CRivasGomez
Copy link
Contributor

CRivasGomez commented Mar 17, 2018

@masters3d I'm a using a mac machine.
I have just tested hello-world exercise and it works perfectly.

➜ tsc -v
Version 2.7.2
➜ yarn -v
1.5.1
➜ node -v
v9.8.0
➜ npm -v
5.6.0

@matthewharwood
Copy link
Author

@CRivasGomez if you complete the task

class HelloWorld {
    static hello( name = 'World' ) {
        return `Hello ${name}!`
    }
}

export default HelloWorld

Do the tests still run or does it get hung up?

@masters3d
Copy link
Contributor

I haven’t been able to reproduce. Sorry. We added Mac builds and they are passing.

@CRivasGomez
Copy link
Contributor

@matthewharwood they run perfectly on my mac.

@masters3d
Copy link
Contributor

reopen if you feel this has not been addressed.

@nandin-borjigin
Copy link

Installation of fsevent of version locked in downloaded yarn.lock file is failed, and installation of subsequent packages are also failed thus causing the hang-on.

Environments:

  • macOS: 10.13.5 (17F77)
  • node: v10.0.0
  • yarn: 1.6.0
  • network: Behind China GFW

Deleting the yarn.lock file before running yarn install would prevent the problem, but also causes the dependency resolution to run on every new exercise and it really takes a lot of time.

@Swizec
Copy link

Swizec commented Feb 20, 2020

For anyone coming here in the future, it's a watchman issue.

This helps: jestjs/jest#4529

@kamkudla
Copy link

kamkudla commented Apr 8, 2020

@Swizec This was it! Solved with brew reinstall watchman

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants