Как я могу исправить: «Ошибка: не удается разрешить« DNS »»? - PullRequest
0 голосов
/ 25 октября 2018

Я запускаю Cypress-тест для получения вызовов.Сервер json работает
Затем я получаю сообщение об ошибке: ./node_modules/fetch/lib/fetch.js Модуль не найден: Ошибка: не удается разрешить 'dns' в> '/ Users / stein / Development / TimeLogging/ TimeLogging / node_modules / fetch / lib 'resol' dns 'in>' / Users / stein / Development / TimeLogging / TimeLogging / node_modules / fetch / lib 'Разобранный запрос представляет собой модуль, использующий файл описания:> / Users / stein / Development /TimeLogging / TimeLogging / node_modules / fetch / package.json (относительный путь: ./lib) Поле 'browser' не содержит допустимого разрешения конфигурации псевдонима в виде модуля

Тест выглядит следующим образом:

import {insertTimer, loadTimer} from '../../src/lib/service/service.jsx'
describe( 'Integration tests of services that all the server', () => {
   beforeEach(()=> {

       cy.request('GET','timers')
          .its('body')
          .each(timer => cy.request('DELETE',`timers/${timer.id }` ))

     })

     it('Insert a timer to the database', () => { 

         const timer = { id: "77d3e1a5-18d1-4341-a4d2-6756427f511f" ,
                   title: "integrasjons test av kule titler"
                 }

        insertTimer(timer). then(response => {  
           expect(response.status).to.eq(201)
         })
        loadTimer.then(response => {
         expect(response.json()).to.equal(timer)
        })
    })

}

)

Код, который я тестирую, выглядит следующим образом:

// @flow
import fetch from 'fetch'
import TimerData from '../../components/TimerData.jsx'

/**
 * Services that communicate with the servere
 */

  export const loadTimers = () => {
        return fetch('http://localhost/3030/timers')
  }

   export const insertTimer = ( timer: typeof TimerData) => {
        return fetch('http://localhost/3030/timers', {
                 method: "POST",
                 headers: {
                   "Content-Type": "application/json; charset=utf-8"
                  },
                body: JSON.stringify(timer)
               })
  }

, а package.json выглядит следующим образом

{
  "name": "TimeLogging",
  "version": "1.0.0",
  "description": "React Time Logging",
  "main": "index.js",
  "engines": {
    "node": "10.10.0",
    "npm": "6.4.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "nyc --reporter=text-lcov cypress run ",
    "coverage": "nyc report --reporter=text-lcov | coveralls",
    "eject": "react-scripts eject",
    "cypress:open": "cypress open",
    "cypress:run": "cypress run",
    "eslint": "eslint",
    "mocha": "mocha",
    "nyc": "nyc",
    "flow": "flow",
    "sinon": "sinon",
    "uuid": "uuid"
  },
  "author": "CodeMix",
  "license": "ISC",
  "dependencies": {
    "prop-types": "^15.6.2",
    "react-scripts": "^2.0.4",
    "react": "^16.5.2",
    "react-dom": "^16.5.2",
    "react-script": "^2.0.5",
    "semantic-ui-react": "^0.82.5"
  },
  "devDependencies": {
    "@babel/core": "^7.1.2",
    "@babel/plugin-proposal-class-properties": "^7.1.0",
    "@babel/preset-env": "^7.1.0",
    "@babel/preset-flow": "^7.0.0",
    "@babel/preset-react": "^7.0.0",
    "@cypress/webpack-preprocessor": "^3.0.0",
    "ajv": "^6.5.4",
    "babel-loader": "^8.0.4",
    "coveralls": "^3.0.2",
    "cypress": "^3.1.0",
    "enzyme": "^3.6.0",
    "enzyme-adapter-react-16": "^1.5.0",
    "eslint": "^5.6.1",
    "eslint-config-standard": "^12.0.0",
    "eslint-plugin-chai-friendly": "^0.4.1",
    "eslint-plugin-cypress": "^2.0.1",
    "eslint-plugin-import": "^2.14.0",
    "eslint-plugin-node": "^7.0.1",
    "eslint-plugin-promise": "^4.0.1",
    "eslint-plugin-react": "^7.11.1",
    "eslint-plugin-standard": "^4.0.0",
    "fetch": "^1.1.0",
    "flow-bin": "^0.83.0",
    "istanbul-lib-instrument": "^3.0.0",
    "nyc": "^13.0.1",
    "sinon": "^7.0.0",
    "webpack": "^4.20.2"
  },
  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
  ],
  "node": {
    "dns": "empty",
    "net": "empty"
 }
}

Сервер json работает

Загрузка db.json Выполнено

Ресурсы http://localhost:3030/timers

Home http://localhost:3030

База данных содержит записи

{
  "timers": [
    {
      "id": "15228f90-6a34-4672-954b-357012f74ed0",
      "title": "stored obejct"
    }
  ]
}

>

Что нужно сделать, чтобы исправить эту ошибку?

...