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

Not refreshing code with mocha --watch when Unable to compile Typescript #113

Closed
suzuki11109 opened this issue May 14, 2016 · 6 comments
Closed
Labels

Comments

@suzuki11109
Copy link

suzuki11109 commented May 14, 2016

I've been using ts-node with mocha for running test. It works fine in watch mode. I can change from failing test to success smoothly. But when code error it shown TSError: ⨯ Unable to compile TypeScript by removing imported dependency. and then I put that dependency back. It's not work as expect.

Here's an example

import {expect} from 'chai';
import fizzbuzz from '../src/fizzbuzz';

describe('fizzbuzz', () => {
  it('input 1 return 1', () => {
    expect(fizzbuzz(1)).to.equal('1');
  });
});

output is (this failing test is OK)

  2 passing (45ms)
  1 failing

  1) fizzbuzz input 1 return 1:
     AssertionError: expected undefined to equal '1'
      at Context.<anonymous> (../../test/test.ts:6:28)

and remove dependency and save file

import {expect} from 'chai';

describe('fizzbuzz', () => {
  it('input 1 return 1', () => {
    expect(fizzbuzz(1)).to.equal('1');
  });
});

and it's ok to error

TSError: ⨯ Unable to compile TypeScript
test/test.ts (6,12): Cannot find name 'fizzbuzz'. (2304)

but when I put it back and save the file

import {expect} from 'chai';
import fizzbuzz from '../src/fizzbuzz';

describe('fizzbuzz', () => {
  it('input 1 return 1', () => {
    expect(fizzbuzz(1)).to.equal('1');
  });
});

mocha's not comming back and the error show up again

TSError: ⨯ Unable to compile TypeScript
test/test.ts (6,12): Cannot find name 'fizzbuzz'. (2304)

This is my mocha opts

--require ts-node/register
--reporter nyan
--watch-extensions tsx,ts
test/**/*.tsx
test/**/*.ts

Please help me
Thanks

@silviogutierrez
Copy link

Can confirm this is happening on my setup as well. But when say, I purposely break a test (by making it fail), and then fix it, it does re-run tests. So only on compilation errors.

@EddyLane
Copy link

This is also happening in my set up. If you set the flags:

TS_NODE_IGNORE_WARNINGS=TRUE TS_NODE_DISABLE_WARNINGS=TRUE

then this doesn't happen, but it silently fails to compile so you don't get compilation errors.

@arusakov
Copy link

arusakov commented Oct 7, 2016

mocha -w and ts-node don't work together in my project too

@Eoksni
Copy link

Eoksni commented Apr 24, 2017

@EddyLane
I think you only need TS_NODE_IGNORE_WARNINGS=TRUE.
It makes it recompile on change even after compilation error and you still get errors when it fails to compile.

@agborkowski
Copy link

agborkowski commented Jan 29, 2018

same here.. TS_NODE_IGNORE_WARNINGS just silent down errors... needs cmd+c and run again

fixed by #266

@cspotcode
Copy link
Collaborator

Closing because the original issue does not happen on the latest ts-node and mocha.

https://github.com/TypeStrong/ts-node-repros/tree/issue-113
https://github.com/TypeStrong/ts-node-repros/runs/1029421954

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

No branches or pull requests

8 participants