Encountering an issue with the signin
function implementation in my application. Despite having a global declaration for this function, I am getting an error stating 'Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature.' Tried multiple solutions without success. Any assistance in resolving this problem would be greatly appreciated.
import request from 'supertest';
import { app } from '../app';
declare global {
namespace NodeJS {
interface Global {
signin: () => Promise<string[]>;
}
}
}
global.signin = async () => {
const email = '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0b7f6e787f4b7f6e787f25686466">[email protected]</a>';
const password = 'password';
const response = await request(app)
.post('/api/users/signup')
.send({
email,
password
})
.expect(201);
const cookie = response.get('Set-Cookie');
return cookie;
};
it('responds with details about the current user', async () => {
const cookie = await global.signin();
const response = await request(app)
.get('/api/users/currentuser')
.set('Cookie', cookie)
.send()
.expect(200);
expect(response.body.currentUser.email).toEqual('<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="dbafbea8af9bafbea8aff5b8b4b6">[email protected]</a>');
});