Skip to content

Commit 46f0b5f

Browse files
committed
chore: so much logging
1 parent e20dfe3 commit 46f0b5f

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

test/index.spec.js

+32-1
Original file line numberDiff line numberDiff line change
@@ -1764,7 +1764,7 @@ const wait = (seconds = 0.5) => new Promise((resolve) => setTimeout(resolve, sec
17641764

17651765
const middlewareExists = () => existsSync(resolve('.netlify', 'middleware.js'))
17661766

1767-
describe.skip('onPreDev', () => {
1767+
describe('onPreDev', () => {
17681768
let runtime
17691769
beforeAll(async () => {
17701770
runtime = await nextRuntimeFactory({}, { events: new Set(['onPreDev']) })
@@ -1795,16 +1795,19 @@ describe('the dev middleware watcher', () => {
17951795
})
17961796

17971797
it('should compile a middleware file and then exit when killed', async () => {
1798+
console.log('starting should compile a middleware file and then exit when killed')
17981799
await moveNextDist('.next', true)
17991800
await writeFile(path.join(process.cwd(), 'middleware.ts'), middlewareSourceTs)
18001801
expect(middlewareExists()).toBeFalsy()
18011802
const { watcher, isReady } = startWatching(process.cwd())
18021803
watchers.push(watcher)
18031804
await isReady
18041805
expect(middlewareExists()).toBeTruthy()
1806+
console.log('done should compile a middleware file and then exit when killed')
18051807
})
18061808

18071809
it('should compile a file if it is written after the watcher starts', async () => {
1810+
console.log('starting should compile a file if it is written after the watcher starts')
18081811
await moveNextDist('.next', true)
18091812
const { watcher, isReady, nextBuild } = startWatching(process.cwd())
18101813
watchers.push(watcher)
@@ -1814,9 +1817,11 @@ describe('the dev middleware watcher', () => {
18141817
await writeFile(path.join(process.cwd(), 'middleware.ts'), middlewareSourceTs)
18151818
await isBuilt
18161819
expect(middlewareExists()).toBeTruthy()
1820+
console.log('done should compile a file if it is written after the watcher starts')
18171821
})
18181822

18191823
it('should remove the output if the middleware is removed after the watcher starts', async () => {
1824+
console.log('starting should remove the output if the middleware is removed after the watcher starts')
18201825
await moveNextDist('.next', true)
18211826
const { watcher, isReady, nextBuild } = startWatching(process.cwd())
18221827
watchers.push(watcher)
@@ -1830,9 +1835,11 @@ describe('the dev middleware watcher', () => {
18301835
await unlink(path.join(process.cwd(), 'middleware.ts'))
18311836
await isBuilt
18321837
expect(middlewareExists()).toBeFalsy()
1838+
console.log('done should remove the output if the middleware is removed after the watcher starts')
18331839
})
18341840

18351841
it('should remove the output if invalid middleware is written after the watcher starts', async () => {
1842+
console.log('starting should remove the output if invalid middleware is written after the watcher starts')
18361843
await moveNextDist('.next', true)
18371844
const { watcher, isReady, nextBuild } = startWatching(process.cwd())
18381845
watchers.push(watcher)
@@ -1846,9 +1853,13 @@ describe('the dev middleware watcher', () => {
18461853
await writeFile(path.join(process.cwd(), 'middleware.ts'), 'this is not valid middleware')
18471854
await isBuilt
18481855
expect(middlewareExists()).toBeFalsy()
1856+
console.log('done should remove the output if invalid middleware is written after the watcher starts')
18491857
})
18501858

18511859
it('should recompile the middleware if it is moved into the src directory after the watcher starts', async () => {
1860+
console.log(
1861+
'starting should recompile the middleware if it is moved into the src directory after the watcher starts',
1862+
)
18521863
await moveNextDist('.next', true)
18531864
const { watcher, isReady, nextBuild } = startWatching(process.cwd())
18541865
watchers.push(watcher)
@@ -1862,9 +1873,13 @@ describe('the dev middleware watcher', () => {
18621873
await move(path.join(process.cwd(), 'middleware.ts'), path.join(process.cwd(), 'src', 'middleware.ts'))
18631874
await isBuilt
18641875
expect(middlewareExists()).toBeTruthy()
1876+
console.log('done should recompile the middleware if it is moved into the src directory after the watcher starts')
18651877
})
18661878

18671879
it('should recompile the middleware if it is moved into the root directory after the watcher starts', async () => {
1880+
console.log(
1881+
'starting should recompile the middleware if it is moved into the root directory after the watcher starts',
1882+
)
18681883
await moveNextDist('.next', true)
18691884
const { watcher, isReady, nextBuild } = startWatching(process.cwd())
18701885
watchers.push(watcher)
@@ -1879,9 +1894,13 @@ describe('the dev middleware watcher', () => {
18791894
await move(path.join(process.cwd(), 'src', 'middleware.ts'), path.join(process.cwd(), 'middleware.ts'))
18801895
await isBuilt
18811896
expect(middlewareExists()).toBeTruthy()
1897+
console.log('done should recompile the middleware if it is moved into the root directory after the watcher starts')
18821898
})
18831899

18841900
it('should compile the middleware if invalid source is replaced with valid source after the watcher starts', async () => {
1901+
console.log(
1902+
'starting should compile the middleware if invalid source is replaced with valid source after the watcher starts',
1903+
)
18851904
await moveNextDist('.next', true)
18861905
const { watcher, isReady, nextBuild } = startWatching(process.cwd())
18871906
watchers.push(watcher)
@@ -1895,9 +1914,13 @@ describe('the dev middleware watcher', () => {
18951914
await writeFile(path.join(process.cwd(), 'middleware.ts'), middlewareSourceTs)
18961915
await isBuilt
18971916
expect(middlewareExists()).toBeTruthy()
1917+
console.log(
1918+
'done should compile the middleware if invalid source is replaced with valid source after the watcher starts',
1919+
)
18981920
})
18991921

19001922
it('should not compile middleware if more than one middleware file exists', async () => {
1923+
console.log('starting should not compile middleware if more than one middleware file exists')
19011924
await moveNextDist('.next', true)
19021925
const { watcher, isReady, nextBuild } = startWatching(process.cwd())
19031926
watchers.push(watcher)
@@ -1908,9 +1931,11 @@ describe('the dev middleware watcher', () => {
19081931
await writeFile(path.join(process.cwd(), 'middleware.js'), middlewareSourceJs)
19091932
await isBuilt
19101933
expect(middlewareExists()).toBeFalsy()
1934+
console.log('done should not compile middleware if more than one middleware file exists')
19111935
})
19121936

19131937
it('should not compile middleware if a second middleware file is added after the watcher starts', async () => {
1938+
console.log('starting should not compile middleware if a second middleware file is added after the watcher starts')
19141939
await moveNextDist('.next', true)
19151940
const { watcher, isReady, nextBuild } = startWatching(process.cwd())
19161941
watchers.push(watcher)
@@ -1924,9 +1949,11 @@ describe('the dev middleware watcher', () => {
19241949
await writeFile(path.join(process.cwd(), 'middleware.js'), middlewareSourceJs)
19251950
await isBuilt
19261951
expect(middlewareExists()).toBeFalsy()
1952+
console.log('done should not compile middleware if a second middleware file is added after the watcher starts')
19271953
})
19281954

19291955
it('should compile middleware if a second middleware file is removed after the watcher starts', async () => {
1956+
console.log('starting should compile middleware if a second middleware file is removed after the watcher starts')
19301957
await moveNextDist('.next', true)
19311958
const { watcher, isReady, nextBuild } = startWatching(process.cwd())
19321959
watchers.push(watcher)
@@ -1943,9 +1970,13 @@ describe('the dev middleware watcher', () => {
19431970
await unlink(path.join(process.cwd(), 'middleware.js'))
19441971
await isBuilt
19451972
expect(middlewareExists()).toBeTruthy()
1973+
console.log('done should compile middleware if a second middleware file is removed after the watcher starts')
19461974
})
19471975

19481976
it('should generate the correct output for each case when middleware is compiled, added, removed and for error states', async () => {
1977+
console.log(
1978+
'starting should generate the correct output for each case when middleware is compiled, added, removed and for error states',
1979+
)
19491980
await moveNextDist('.next', true)
19501981
const consoleLogSpy = jest.spyOn(console, 'log').mockImplementation(() => {})
19511982
const consoleErrorSpy = jest

0 commit comments

Comments
 (0)