2016-07-11 4 views
1

WebStorm IDE에서 개발 한 nodejs 프로젝트가 있습니다. 내 단위 테스트 프레임 워크로 supertest와 함께 Mocha를 사용하고 있습니다.WebStorm에서 supertest를 사용하면 '매개 변수 유형에 인수 유형을 할당 할 수 없습니다.'및 '해결되지 않은 함수 또는 메소드'

WebStorm은 Argument type app|exports|module.exports is not assignable to parameter type Function|ServerUnresolved function or method get()의 두 가지 경고를 표시했습니다.

File -> Settings -> Languages & Frameworks -> JavaScript -> Libraries -> Download에서 supertest 라이브러리를 다운로드하고 설치하려고했지만 아무 일도 일어나지 않았습니다. 따라서 https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/supertest에서 직접 다운로드하여 수동으로 추가했지만 WebStorm은 여전히 ​​동일한 경고를 생성합니다.

이 내 server.js 코드 :

const express = require('express'); 
const app = express(); 

app.get('/', (req, res) => { 
    res.status(200).end(); 
}); 

app.listen(3000); 

module.exports = app; 

이 내 servertest.js 코드 : 나는 이러한 경고를 제거하려면 어떻게

/* eslint-env mocha*/ 

const request = require('supertest'); 
const app = require('../server'); 

describe('GET /',() => { 
    it('should respond OK', (done) => { 
    request(app) //Argument type app|exports|module.exports is not 
       //assignable to parameter type Function|Server 
     .get('/') //Unresolved function or method 
     .expect(200, done); 
    }); 
}); 

? 나를 위해

답변

1

작품 미세 (WebStorm 2016.2) :

enter image description here

사용 라이브러리 : Node.js Core, ECMAScript 6, HTML, HTML5/ECMAScript5, Jasmine Definitely Typed. WebStorm은 Mocha node_modules에서 'describe()'등을 해결할 수 있지만 실제로 재 스민 제품에 대한 수입 누락에 대한 검사는 피할 수 있으므로 후자는 실제로 필요하지 않습니다.

귀하의 프로젝트에 정의 중 하나 인 request 정의와 충돌하는 일부 정의가있는 것 같습니다. request을 Ctrl + 클릭 할 때 어떤 코드를 사용합니까?

+0

내가 Ctrl 키를 누른 상태에서'request'를 클릭하면 node_modules/supertest/index.js로 이동합니다. –

+0

미래의 Google 직원을 위해'jasmine-DefinitelyTyped' 추가는 검사를 수정합니다 "인수 유형 함수를 매개 변수 유형 ActionFunction에 할당 할 수 없습니다" – Kelvin

관련 문제