2015-01-24 23 views
7

Tôi vừa mới bắt đầu với Jest hôm nay. Tôi có một tệp thử nghiệm đơn giản trong thư mục __tests__ của tôi. Đây là tệp thử nghiệm hiện tại:Tôi không thể chạy nhiều tệp thử nghiệm với Jest?

describe('ChangeCalendarView', function() { 
    it('true', function() { 
     expect(3).toBe(3); 
    }) 
}); 

Điều này không có vấn đề gì. Khi tôi thêm tập tin khác, với mã chính xác cùng, khác với mô tả:

describe('ChangeTimePeriod', function() { 
    it('true', function() { 
     expect(3).toBe(3); 
    }) 
}); 

Sau đó, tôi nhận được lỗi này:

/usr/local/lib/node_modules/jest-cli/node_modules/node-worker-pool/Worker.js:93 
    throw new Error('Received unexpected data from child process: ' + data); 
     ^
Error: Received unexpected data from child process: { 
    "error": "Error: ENOENT, open '/usr/local/lib/node_modules/jest-cli/.haste_cache/cache-react-calendar-component'\n\n" 
} 
    at Worker._onStdout (/usr/local/lib/node_modules/jest-cli/node_modules/node-worker-pool/Worker.js:93:11) 

Liệu điều này làm cho tinh thần để bất cứ ai?

+0

Hmm, phải có cái gì khác xảy ra ở đây, hoặc trong môi trường của bạn hoặc xung quanh những khối thi. Điều này có xảy ra khi bạn thêm _any_ tệp thử nghiệm mới hoặc chỉ một tệp cụ thể không? –

+1

Bất kỳ tệp nào tôi thêm đều làm cho cùng một điều xảy ra. Nhưng nếu tôi chỉ để lại một tệp, nó sẽ luôn chạy – jhamm

+0

Tên tệp của các thử nghiệm là gì? Tôi tự hỏi nếu nó là một vấn đề đậu xe với jest. Ngoài ra, nó có vẻ ngớ ngẩn, nhưng tôi cũng cố gắng thổi đi node_modules và chạy npm cài đặt lại. –

Trả lời

3

Tôi đã khắc phục vấn đề này bằng cách sử dụng babel-jest. Dưới đây package.json tôi

{ 
    "name": "myapp", 
    "version": "0.0.0", 
    "dependencies": { 
    "classnames": "^2.1.3", 
    "dev": "^0.1.3", 
    "flux": "^2.0.3", 
    "grunt": "^0.4.5", 
    "gulp": "^3.9.0", 
    "immutable": "^3.7.4", 
    "install": "^0.1.8", 
    "lodash": "^3.10.0", 
    "node-simple-static-server": "^1.1.0", 
    "react-bootstrap": "^0.23.7", 
    "react-router": "^0.13.3", 
    "react-router-bootstrap": "^0.18.0", 
    "react-tools": "^0.13.0-beta.2", 
    "stackup": "^1.0.1" 
    }, 
    "devDependencies": { 
    "babel-jest": "^5.3.0", 
    "babelify": "^6.1.2", 
    "browser-sync": "latest", 
    "browserify-shim": "^3.8.0", 
    "del": "~0.1.3", 
    "gulp-autoprefixer": "~1.0.1", 
    "gulp-bower": "0.0.6", 
    "gulp-cache": "~0.2.4", 
    "gulp-imagemin": "latest", 
    "gulp-jshint": "~1.8.5", 
    "gulp-load-plugins": "~0.7.0", 
    "gulp-ruby-sass": "~0.7.1", 
    "gulp-size": "~1.1.0", 
    "gulp-strip-debug": "^1.0.2", 
    "gulp-stylus": "~2.0.1", 
    "gulp-uglify": "^1.0.2", 
    "gulp-useref": "~0.4.4", 
    "gulp-util": "~3.0.1", 
    "gulp-webserver": "latest", 
    "jest-cli": "*", 
    "main-bower-files": "~2.6.2", 
    "react": "latest", 
    "react-tools": "latest", 
    "reactify": "latest", 
    "strip-debug": "^1.0.1", 
    "vinyl-source-stream": "^1.0.0", 
    "watchify": "~2.1" 
    }, 
    "engines": { 
    "node": ">=0.10.0" 
    }, 
    "scripts": { 
    "test": "jest" 
    }, 
    "jest": { 
    "scriptPreprocessor": "../node_modules/babel-jest", 
    "testFileExtensions": [ 
     "es6", 
     "js" 
    ], 
    "moduleFileExtensions": [ 
     "js", 
     "json", 
     "es6" 
    ], 
    "rootDir": "./app", 
    "collectCoverage": true, 
    "unmockedModulePathPatterns": [ 
     "react", 
     "events", 
     "lodash" 
    ] 
    }, 
    "browserify": { 
    "transform": [ 
     "browserify-shim", 
     [ 
     "reactify", 
     { 
      "es6": true 
     } 
     ] 
    ] 
    }, 
    "browser": { 
    "jquery": "./app/bower_components/jquery/dist/jquery.js" 
    }, 
    "browserify-shim": { 
    "jquery": "$" 
    } 
} 

screen result

Các vấn đề liên quan