eugef / node-mocks-http

Mock 'http' objects for testing Express routing functions
Other
747 stars 131 forks source link

Unable to test the structured session data with typescript. #205

Closed u4da3 closed 4 years ago

u4da3 commented 4 years ago

I'm testing the structured session data with typescript. But the test does not work because of the type error.

For example, in express-session, the type definition of SessionData is as below:

interface SessionData {
  [key: string]: any;
  cookie: SessionCookieData;
}

But, the type definition in node-mocks-http is as below:

export interface Session {
  [key: string]: string;
}

I tyied rewriting the type definition in node-mocks-http: [key: string]: string; -> [key: string]: any; And the test works successfully.

eugef commented 4 years ago

Hi @u4da3, would be great if you create a PR with the fix