Skip to content

Commit f41101c

Browse files
authored
test(structured-logging): adjust for v4 (#33234)
1 parent 0eba911 commit f41101c

File tree

2 files changed

+19
-6
lines changed
  • integration-tests/structured-logging/__tests__
  • packages/gatsby/src/commands

2 files changed

+19
-6
lines changed

integration-tests/structured-logging/__tests__/to-do.js

+18-6
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ const joi = require(`joi`)
1414
// const { inspect } = require(`util`)
1515

1616
// https://stackoverflow.com/questions/12756159/regex-and-iso8601-formatted-datetime
17-
const ISO8601 = /^\d{4}(-\d\d(-\d\d(T\d\d:\d\d(:\d\d)?(\.\d+)?(([+-]\d\d:\d\d)|Z)?)?)?)?$/i
17+
const ISO8601 =
18+
/^\d{4}(-\d\d(-\d\d(T\d\d:\d\d(:\d\d)?(\.\d+)?(([+-]\d\d:\d\d)|Z)?)?)?)?$/i
1819

1920
jest.setTimeout(100000)
2021

@@ -76,7 +77,8 @@ const toMatchSchema = (received, schema) => {
7677
}
7778
} else {
7879
return {
79-
message: () => validationResult.error,
80+
message: () =>
81+
`${validationResult.error}\n\n${JSON.stringify(received, null, 2)}`,
8082
pass: false,
8183
}
8284
}
@@ -121,7 +123,18 @@ const commonAssertions = events => {
121123
// Should this be here or one level up?
122124
timestamp: joi.string().required(),
123125
})
124-
.required()
126+
.required(),
127+
128+
joi.object({
129+
type: joi.string().required().valid(`ENGINES_READY`),
130+
timestamp: joi.string().required(),
131+
}),
132+
133+
joi.object({
134+
type: joi.string().required().valid(`RENDER_PAGE_TREE`),
135+
payload: joi.object(),
136+
timestamp: joi.string().required(),
137+
})
125138
)
126139

127140
const eventSchema = joi.object({
@@ -292,9 +305,8 @@ describe(`develop`, () => {
292305
let events = []
293306

294307
beforeAll(done => {
295-
const { finishedPromise, gatsbyProcess } = collectEventsForDevelop(
296-
events
297-
)
308+
const { finishedPromise, gatsbyProcess } =
309+
collectEventsForDevelop(events)
298310

299311
setTimeout(() => {
300312
gatsbyProcess.kill(`SIGTERM`)

packages/gatsby/src/commands/build.ts

+1
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ module.exports = async function build(program: IBuildArgs): Promise<void> {
259259
type: `LOG_ACTION`,
260260
action: {
261261
type: `ENGINES_READY`,
262+
timestamp: new Date().toJSON(),
262263
},
263264
})
264265
}

0 commit comments

Comments
 (0)