Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[PLAY-297] Fixing Jest Test that Breaks CI Intermittently #2034

Merged
merged 2 commits into from
Aug 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@ import { fireEvent, render, screen, waitFor, within } from '../utilities/test-ut
import DatePicker from './_date_picker'
import { getTimezoneText } from './plugins/timeSelect'



jest.setSystemTime(new Date('01/01/2020'));
const DEFAULT_DATE = new Date()
DEFAULT_DATE.setFullYear(2022)
DEFAULT_DATE.setMonth(1)
DEFAULT_DATE.setDate(1)
DEFAULT_DATE.setHours(12)
DEFAULT_DATE.setMinutes(0)


describe('DatePicker Kit', () => {
beforeEach(() => {
jest.spyOn(console, 'error').mockImplementation(() => {});
jest.spyOn(console, 'error').mockImplementation(() => { });
});

test('renders DatePicker input field', () => {
Expand Down Expand Up @@ -44,10 +43,12 @@ describe('DatePicker Kit', () => {

const kit = screen.getByTestId(testId)


const input = within(kit).getByPlaceholderText('Select Date')
expect(input).toBeInTheDocument()

await waitFor(() => {
expect(input).toHaveValue('02/01/2022')
expect(input).toHaveValue('01/01/2020')
})
})

Expand Down Expand Up @@ -143,7 +144,7 @@ describe('DatePicker Kit', () => {
}),
)
await waitFor(() => {
expect(input).toHaveValue('02/01/2022 at 12:00 AM')
expect(input).toHaveValue('01/01/2020 at 12:00 AM')
})

fireEvent(
Expand All @@ -154,7 +155,7 @@ describe('DatePicker Kit', () => {
}),
)
await waitFor(() => {
expect(input).toHaveValue('02/01/2022 at 12:00 PM')
expect(input).toHaveValue('01/01/2020 at 12:00 PM')
})
})
})
2 changes: 1 addition & 1 deletion playbook/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ module.exports = {
// testURL: "http://localhost",

// Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
// timers: "real",
timers: "modern",

// A map from regular expressions to paths to transformers
// transform: undefined,
Expand Down