Skip to content
Merged
13 changes: 6 additions & 7 deletions configurations/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface ConfigOptions {
poolStrategy: 'threads' | 'forks'
}

export default function config(packagePath: string, {poolStrategy}: ConfigOptions = {poolStrategy: 'forks'}) {
export default function config(packagePath: string, {poolStrategy}: ConfigOptions = {poolStrategy: 'threads'}) {
// always treat environment as one that doesn't support hyperlinks -- otherwise assertions are hard to keep consistent
process.env.FORCE_HYPERLINK = '0'
process.env.FORCE_COLOR = '1'
Expand All @@ -28,6 +28,11 @@ export default function config(packagePath: string, {poolStrategy}: ConfigOption
}

return defineConfig({
define: {
'process.env.SHOPIFY_UNIT_TEST': '"1"',
'process.env.FORCE_HYPERLINK': '"0"',
'process.env.FORCE_COLOR': '"1"',
},
resolve: {
alias: aliases(packagePath) as AliasOptions,
},
Expand All @@ -45,10 +50,6 @@ export default function config(packagePath: string, {poolStrategy}: ConfigOption
reporter: ['text', 'json', 'lcov'],
exclude: ['**/src/**/vendor/**'],
},
snapshotFormat: {
escapeString: true,
},
includeSource: ['**/src/**/*.{ts,tsx}'],
sequence: {
hooks: 'list',
},
Expand All @@ -58,8 +59,6 @@ export default function config(packagePath: string, {poolStrategy}: ConfigOption
'clearTimeout',
'setInterval',
'clearInterval',
'setImmediate',
'clearImmediate',
'Date',
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,29 +124,29 @@ describe('Logs', () => {
const lastFrame = renderInstance.lastFrame()

expect(unstyled(lastFrame!)).toMatchInlineSnapshot(`
"2024-06-18 16:02:04.868 my-store my-function Success export \\"run\\" executed in 0.5124M instructions
test logs
"2024-06-18 16:02:04.868 my-store my-function Success export "run" executed in 0.5124M instructions
test logs

Input Query Variables:
Input Query Variables:

Namespace: inputQueryVariablesMetafieldNamespace
Key: inputQueryVariablesMetafieldKey
Namespace: inputQueryVariablesMetafieldNamespace
Key: inputQueryVariablesMetafieldKey

{
\\"key\\": \\"value\\"
}
{
"key": "value"
}

Input (10 bytes):
Input (10 bytes):

{
\\"test\\": \\"input\\"
}
{
"test": "input"
}

Output (10 bytes):
Output (10 bytes):

{
\\"test\\": \\"output\\"
}"
{
"test": "output"
}"
`)

renderInstance.unmount()
Expand Down Expand Up @@ -174,7 +174,7 @@ describe('Logs', () => {
const lastFrame = renderInstance.lastFrame()

expect(unstyled(lastFrame!)).toMatchInlineSnapshot(`
"2024-06-18 16:02:04.868 my-store my-function Success export \\"run\\" executed in 0.5124M instructions
"2024-06-18 16:02:04.868 my-store my-function Success export "run" executed in 0.5124M instructions
test logs

Input Query Variables:
Expand All @@ -187,15 +187,15 @@ describe('Logs', () => {
Input (10 bytes):

{
\\"test\\": \\"input\\"
"test": "input"
}

Output (10 bytes):

{
\\"test\\": \\"output\\"
"test": "output"
}"
`)
`)

renderInstance.unmount()
})
Expand Down Expand Up @@ -225,20 +225,20 @@ describe('Logs', () => {
const lastFrame = renderInstance.lastFrame()

expect(unstyled(lastFrame!)).toMatchInlineSnapshot(`
"2024-06-18 16:02:04.868 my-store my-function Success export \\"run\\" executed in 0.5124M instructions
test logs
"2024-06-18 16:02:04.868 my-store my-function Success export "run" executed in 0.5124M instructions
test logs

Input (10 bytes):
Input (10 bytes):

{
\\"test\\": \\"input\\"
}
{
"test": "input"
}

Output (10 bytes):
Output (10 bytes):

{
\\"test\\": \\"output\\"
}"
{
"test": "output"
}"
`)

renderInstance.unmount()
Expand Down Expand Up @@ -280,27 +280,27 @@ describe('Logs', () => {
const lastFrame = renderInstance.lastFrame()

expect(unstyled(lastFrame!)).toMatchInlineSnapshot(`
"2024-06-18 16:02:04.868 my-store my-function Success network access response from cache
Cache write time: 2023-05-12T15:17:01.000Z
Cache TTL: 300 s
HTTP request:
{
\\"url\\": \\"https://api.example.com/hello\\",
\\"method\\": \\"GET\\",
\\"headers\\": {},
\\"body\\": null,
\\"policy\\": {
\\"read_timeout_ms\\": 500
}
}
HTTP response:
{
\\"status\\": 200,
\\"body\\": \\"Success\\",
\\"headers\\": {
\\"header1\\": \\"value1\\"
"2024-06-18 16:02:04.868 my-store my-function Success network access response from cache
Cache write time: 2023-05-12T15:17:01.000Z
Cache TTL: 300 s
HTTP request:
{
"url": "https://api.example.com/hello",
"method": "GET",
"headers": {},
"body": null,
"policy": {
"read_timeout_ms": 500
}
}
}"
HTTP response:
{
"status": 200,
"body": "Success",
"headers": {
"header1": "value1"
}
}"
`)

renderInstance.unmount()
Expand Down Expand Up @@ -342,28 +342,28 @@ describe('Logs', () => {
const lastFrame = renderInstance.lastFrame()

expect(unstyled(lastFrame!)).toMatchInlineSnapshot(`
"2024-06-18 16:02:04.868 my-store my-function Success network access request executed in 80 ms
Attempt: 1
Connect time: 40 ms
Write read time: 40 ms
HTTP request:
{
\\"url\\": \\"https://api.example.com/hello\\",
\\"method\\": \\"GET\\",
\\"headers\\": {},
\\"body\\": null,
\\"policy\\": {
\\"read_timeout_ms\\": 500
"2024-06-18 16:02:04.868 my-store my-function Success network access request executed in 80 ms
Attempt: 1
Connect time: 40 ms
Write read time: 40 ms
HTTP request:
{
"url": "https://api.example.com/hello",
"method": "GET",
"headers": {},
"body": null,
"policy": {
"read_timeout_ms": 500
}
}
}
HTTP response:
{
\\"status\\": 200,
\\"body\\": \\"Success\\",
\\"headers\\": {
\\"header1\\": \\"value1\\"
}
}"
HTTP response:
{
"status": 200,
"body": "Success",
"headers": {
"header1": "value1"
}
}"
`)

renderInstance.unmount()
Expand Down Expand Up @@ -405,19 +405,19 @@ describe('Logs', () => {
const lastFrame = renderInstance.lastFrame()

expect(unstyled(lastFrame!)).toMatchInlineSnapshot(`
"2024-06-18 16:02:04.868 my-store my-function Failure network access request executed
Attempt: 1
HTTP request:
{
\\"url\\": \\"https://api.example.com/hello\\",
\\"method\\": \\"GET\\",
\\"headers\\": {},
\\"body\\": null,
\\"policy\\": {
\\"read_timeout_ms\\": 500
"2024-06-18 16:02:04.868 my-store my-function Failure network access request executed
Attempt: 1
HTTP request:
{
"url": "https://api.example.com/hello",
"method": "GET",
"headers": {},
"body": null,
"policy": {
"read_timeout_ms": 500
}
}
}
Error: Timeout Error"
Error: Timeout Error"
`)

renderInstance.unmount()
Expand Down Expand Up @@ -455,18 +455,18 @@ describe('Logs', () => {
const lastFrame = renderInstance.lastFrame()

expect(unstyled(lastFrame!)).toMatchInlineSnapshot(`
"2024-06-18 16:02:04.868 my-store my-function Success network access request executing in background
Reason: No cached response available
HTTP request:
{
\\"url\\": \\"https://api.example.com/hello\\",
\\"method\\": \\"GET\\",
\\"headers\\": {},
\\"body\\": null,
\\"policy\\": {
\\"read_timeout_ms\\": 500
}
}"
"2024-06-18 16:02:04.868 my-store my-function Success network access request executing in background
Reason: No cached response available
HTTP request:
{
"url": "https://api.example.com/hello",
"method": "GET",
"headers": {},
"body": null,
"policy": {
"read_timeout_ms": 500
}
}"
`)

renderInstance.unmount()
Expand Down Expand Up @@ -504,18 +504,18 @@ describe('Logs', () => {
const lastFrame = renderInstance.lastFrame()

expect(unstyled(lastFrame!)).toMatchInlineSnapshot(`
"2024-06-18 16:02:04.868 my-store my-function Success network access request executing in background
Reason: Cache is about to expire
HTTP request:
{
\\"url\\": \\"https://api.example.com/hello\\",
\\"method\\": \\"GET\\",
\\"headers\\": {},
\\"body\\": null,
\\"policy\\": {
\\"read_timeout_ms\\": 500
}
}"
"2024-06-18 16:02:04.868 my-store my-function Success network access request executing in background
Reason: Cache is about to expire
HTTP request:
{
"url": "https://api.example.com/hello",
"method": "GET",
"headers": {},
"body": null,
"policy": {
"read_timeout_ms": 500
}
}"
`)

renderInstance.unmount()
Expand Down
Loading
Loading