Skip to content

Commit 113e7fc

Browse files
committed
Use env var to switch logging config in test app
1 parent 72302a0 commit 113e7fc

File tree

2 files changed

+23
-24
lines changed

2 files changed

+23
-24
lines changed
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module.exports = {
2-
logging: {
3-
serverFunctions: true,
4-
},
2+
logging:
3+
process.env.NEXT_TEST_SERVER_FUNCTION_LOGGING === 'true'
4+
? { serverFunctions: true }
5+
: undefined,
56
}

test/e2e/app-dir/server-action-logging/server-action-logging.test.ts

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ describe('server-action-logging', () => {
66
const { next, isNextStart, skipped } = nextTestSetup({
77
skipDeployment: true,
88
files: __dirname,
9+
env: {
10+
NEXT_TEST_SERVER_FUNCTION_LOGGING: 'true',
11+
},
912
})
1013

1114
if (skipped) return
@@ -186,32 +189,27 @@ describe('server-action-logging', () => {
186189
expect(logs).not.toContain('test/e2e/app-dir/server-action-logging/')
187190
})
188191
})
192+
})
189193

190-
describe('when logging.serverFunctions is not enabled', () => {
191-
beforeAll(async () => {
192-
await next.patchFile('next.config.js', (content) =>
193-
content.replace('serverFunctions: true', '// serverFunctions: true')
194-
)
195-
})
194+
describe('server-action-logging when logging.serverFunctions is not enabled', () => {
195+
const { next, skipped } = nextTestSetup({
196+
skipDeployment: true,
197+
files: __dirname,
198+
})
196199

197-
afterAll(async () => {
198-
await next.patchFile('next.config.js', (content) =>
199-
content.replace('// serverFunctions: true', 'serverFunctions: true')
200-
)
201-
})
200+
if (skipped) return
202201

203-
it('should not log server actions', async () => {
204-
const browser = await next.browser('/')
205-
const outputIndex = next.cliOutput.length
202+
it('should not log server actions', async () => {
203+
const browser = await next.browser('/')
204+
const outputIndex = next.cliOutput.length
206205

207-
await browser.elementByCss('#success-action').click()
208-
await browser.waitForElementByCss('#result')
206+
await browser.elementByCss('#success-action').click()
207+
await browser.waitForElementByCss('#result')
209208

210-
await retry(() => {
211-
const logs = stripAnsi(next.cliOutput.slice(outputIndex))
212-
expect(logs).toContain('POST /')
213-
expect(logs).not.toContain('└─ ƒ successAction')
214-
})
209+
await retry(() => {
210+
const logs = stripAnsi(next.cliOutput.slice(outputIndex))
211+
expect(logs).toContain('POST /')
212+
expect(logs).not.toContain('└─ ƒ successAction')
215213
})
216214
})
217215
})

0 commit comments

Comments
 (0)