Skip to content

Commit

Permalink
Run tests from the command line
Browse files Browse the repository at this point in the history
  • Loading branch information
kulshekhar committed Dec 18, 2017
1 parent ee71dce commit efc8dbc
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 21 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Expand Up @@ -11,6 +11,7 @@ before_install:
before_script:
# - greenkeeper-lockfile-update
script:
- yarn test
- yarn test:prepare
- ./node_modules/.bin/jest --no-cache
after_script:
# - greenkeeper-lockfile-upload
5 changes: 3 additions & 2 deletions appveyor.yml
Expand Up @@ -12,9 +12,9 @@ init:
# what combinations to test
environment:
matrix:
- nodejs_version: 4
- nodejs_version: 6
- nodejs_version: 8
- nodejs_version: 9

# get the latest stable version of Node 0.STABLE.latest
install:
Expand All @@ -30,4 +30,5 @@ test_script:
- node --version
- npm --version
- yarn --version
- cmd: yarn test
- cmd: yarn test:prepare
- cmd: ./node_modules/.bin/jest --no-cache
6 changes: 5 additions & 1 deletion package.json
Expand Up @@ -10,7 +10,7 @@
"clean": "rimraf dist/**/* && rimraf tests/simple/coverage && rimraf tests/simple-async/coverage",
"clean-build": "npm run clean && npm run build",
"pretest": "npm run tslint && npm run clean-build",
"test": "node scripts/tests.js",
"test:prepare": "node scripts/tests.js",
"tslint": "tslint src/*.ts",
"doc": "doctoc .",
"prepublish": "npm run clean-build",
Expand Down Expand Up @@ -49,6 +49,10 @@
"^.+\\.tsx?$": "<rootDir>/dist/preprocessor.js"
},
"testRegex": "tests/__tests__/.*\\.spec\\.ts$",
"testPathIgnorePatterns": [
"/node_modules/",
"tests/__tests__/watch.spec.ts"
],
"coverageReporters": [
"text"
],
Expand Down
14 changes: 0 additions & 14 deletions scripts/tests.js
Expand Up @@ -64,17 +64,3 @@ function createIntegrationMock() {
}

createIntegrationMock();

const argv = process.argv.slice(2);
argv.push('--no-cache');
// Watch unless on CI
if (!process.env.CI) {
// argv.push('--watch');
}
// omit tests for watch cases if it runned on AppVeyor due to this issues:
// https://github.com/kulshekhar/ts-jest/issues/53
// http://help.appveyor.com/discussions/problems/5500-nodejs-child-process-with-watch-and-stderr-problem

argv.push('--testPathPattern', '^(?!(.*watch.spec.ts$)).*');

jest.run(argv);
7 changes: 4 additions & 3 deletions tests/__tests__/watch.spec.ts
Expand Up @@ -59,8 +59,8 @@ describe('Typescript watch tests', () => {

beforeAll(() => {
result = runJestInWatchMode('../watch-test');
DEFAULT_TIMEOUT_INTERVAL = jasmine['DEFAULT_TIMEOUT_INTERVAL'];
jasmine['DEFAULT_TIMEOUT_INTERVAL'] = 10000;
DEFAULT_TIMEOUT_INTERVAL = jasmine.DEFAULT_TIMEOUT_INTERVAL;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
});

it('should show the correct error locations in the typescript files without changes', () => {
Expand All @@ -82,6 +82,7 @@ describe('Typescript watch tests', () => {
return promise;
});

// tslint:disable-next-line:max-line-length
it('should show the correct error locations in the typescript files with changes in source file and test file', () => {
let promise = result.getStderrAsync().then(stderr => {
expect(stderr).toContain('Hello.ts:11:11');
Expand All @@ -97,7 +98,7 @@ describe('Typescript watch tests', () => {
afterAll(() => {
result.childProcess.kill();
// revert changes back
jasmine['DEFAULT_TIMEOUT_INTERVAL'] = DEFAULT_TIMEOUT_INTERVAL;
jasmine.DEFAULT_TIMEOUT_INTERVAL = DEFAULT_TIMEOUT_INTERVAL;
fs.writeFileSync(
path.resolve(__dirname, '../watch-test/Hello.ts'),
helloFile,
Expand Down

0 comments on commit efc8dbc

Please sign in to comment.