WebStorm IDE에서 개발 한 nodejs 프로젝트가 있습니다. 내 단위 테스트 프레임 워크로 supertest와 함께 Mocha를 사용하고 있습니다.WebStorm에서 supertest를 사용하면 '매개 변수 유형에 인수 유형을 할당 할 수 없습니다.'및 '해결되지 않은 함수 또는 메소드'
WebStorm은 Argument type app|exports|module.exports is not assignable to parameter type Function|Server
및 Unresolved 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);
});
});
? 나를 위해
내가 Ctrl 키를 누른 상태에서'request'를 클릭하면 node_modules/supertest/index.js로 이동합니다. –
미래의 Google 직원을 위해'jasmine-DefinitelyTyped' 추가는 검사를 수정합니다 "인수 유형 함수를 매개 변수 유형 ActionFunction에 할당 할 수 없습니다" – Kelvin