'Struggling to have DayJs available for all tests in cypress
I'm currently starting a new Cypress project, the application to test is quite "calendar centered" and I'll have to play a lot with dates.
My issue is I can't get DayJs available for the whole project without having to import it in every spec files.
For instance, in a test.spec.ts, this is working
import dayjs = require('dayjs');
describe('Some suite', () => {
it('Some Test', () => {
// some stuff
const myDate = dayjs('11-11-2022', 'dd-MM-YYYY' );
// other stuff
})
})
But when I do this in support/index.ts
import dayjs = require('dayjs')
declare namespace Cypress {
interface Cypress {
dayjs: dayjs.Dayjs;
}
}
and then this in my spec
describe('Some suite', () => {
it('Some Test', () => {
// some stuff
const myDate = Cypress.dayjs('11-11-2022', 'dd-MM-YYYY' );
// other stuff
})
})
it says
Cypress.dayjs is not a function
Any idea on how I could get this work? Thanks for the help
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
