मैं प्रतिक्रिया-मूल परियोजना बनाने के लिए प्रतिक्रिया-मूल init का उपयोग कर रहा हूं। मैं SQLite बाइंडिंग के लिए https://github.com/andpor/react-native-sqlite-storage लाइब्रेरी का उपयोग कर रहा हूं।बाहरी प्लगइन का उपयोग कर प्रतिक्रिया-मूल में जेस्ट टेस्ट केस त्रुटि
मेरे पास एक DbConnector.jest-test.js यूनिट परीक्षण फ़ाइल है। सामग्री
import DbConnector from '../app/components/DbConnector.js';
// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';
it('renders correctly',() => {
const tree = renderer.create(
<DbConnector />
);
});
हैं जब मैं हंसी चला रहा हूँ, मैं निम्न त्रुटि भले ही डिफ़ॉल्ट रूप से node_modules अनदेखी कर रहे हैं हो रही है। मैं package.json में प्रतिक्रिया देशी पूर्व निर्धारित का उपयोग कर रहा
Test suite failed to run
ReferenceError: window is not defined
at Object.<anonymous> (node_modules/react-native-sqlite-storage/lib/sqlite.core.js:53:10)
at Object.<anonymous> (node_modules/react-native-sqlite-storage/sqlite.js:10:12)
at Object.<anonymous> (app/components/DbConnector.js:3:31)
Test Suites: 1 failed, 1 total
DbConnector.js में आयात के रूप में कर रहे हैं:
import React, { Component } from 'react'
import { AppRegistry, StyleSheet, Text, View, TextInput, Button, Alert,
AsyncStorage } from 'react-native'
import SQLite from 'react-native-sqlite-storage'