2017-04-19 66 views
0

我正在使用JEST框架進行單元測試。我正在使用淺源DOM進行DOM測試。運行jest命令後,我收到以下警告。反應原生:淺呈現器的警告

PASS 測試 /CheckboxWithLabel-test.js

●控制檯 console.error node_modules/FBJS/LIB/warning.js:36 警告:淺渲染器已經被移動到反應試驗渲染器/淺。更新引用來移除此警告。

我的測試是

import React from 'react'; 
 
import {shallow} from 'enzyme'; 
 
import CheckboxWithLabel from '../app/Component8/CheckboxWithLabel'; 
 

 
test('CheckboxWithLabel changes the text after click',() => { 
 
    // Render a checkbox with label in the document 
 
    const checkbox = shallow(
 
    <CheckboxWithLabel labelOn="On" labelOff="Off" /> 
 
); 
 
    
 
    expect(checkbox.text()).toEqual('Off'); 
 

 
    checkbox.find('input').simulate('change'); 
 

 
    expect(checkbox.text()).toEqual('On'); 
 
});

我的package.json

{ 
 
    "name": "myapp", 
 
    "version": "0.0.1", 
 
    "private": true, 
 
    "scripts": { 
 
    "start": "node node_modules/react-native/local-cli/cli.js start", 
 
    "test": "jest" 
 
    }, 
 
    "dependencies": { 
 
    "linkify-it": "^2.0.3", 
 
    "prop-types": "^15.5.8", 
 
    "react": "16.0.0-alpha.6", 
 
    "react-dom": "^15.4.2", 
 
    "react-native": "0.43.1" 
 
    }, 
 
    "devDependencies": { 
 
    "babel-jest": "19.0.0", 
 
    "babel-preset-es2015": "^6.24.0", 
 
    "babel-preset-react-native": "1.9.1", 
 
    "enzyme": "^2.8.2", 
 
    "jest": "19.0.2", 
 
    "react-addons-test-utils": "~15.1.0", 
 
    "react-test-renderer": "16.0.0-alpha.6" 
 
    }, 
 
    "jest": { 
 
    "preset": "react-native" 
 
    } 
 
}

+0

檢查這個[問題](HTTPS ://github.com/airbnb/enzyme/issues/875)在酶節點模塊中 –

回答

1

從酶文檔:

如果您使用的陣營> = 15.5,除酶,你必須確保你也有,如果他們不是已經安裝了下列NPM模塊:

npm i --save-dev react-test-renderer react-dom