Skip to content

Commit 0f9e28b

Browse files
committed
chore: so much logging
1 parent e20dfe3 commit 0f9e28b

File tree

1 file changed

+39
-3
lines changed

1 file changed

+39
-3
lines changed

test/index.spec.js

+39-3
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']) })
@@ -1786,25 +1786,33 @@ describe.skip('onPreDev', () => {
17861786
})
17871787
})
17881788

1789-
describe('the dev middleware watcher', () => {
1789+
fdescribe('the dev middleware watcher', () => {
17901790
const watchers = []
17911791

17921792
afterEach(async () => {
1793-
await Promise.all(watchers.map((watcher) => watcher.close()))
1793+
await Promise.all(
1794+
watchers.map((watcher) => {
1795+
console.log('closing watcher')
1796+
return watcher.close()
1797+
}),
1798+
)
17941799
watchers.length = 0
17951800
})
17961801

17971802
it('should compile a middleware file and then exit when killed', async () => {
1803+
console.log('starting should compile a middleware file and then exit when killed')
17981804
await moveNextDist('.next', true)
17991805
await writeFile(path.join(process.cwd(), 'middleware.ts'), middlewareSourceTs)
18001806
expect(middlewareExists()).toBeFalsy()
18011807
const { watcher, isReady } = startWatching(process.cwd())
18021808
watchers.push(watcher)
18031809
await isReady
18041810
expect(middlewareExists()).toBeTruthy()
1811+
console.log('done should compile a middleware file and then exit when killed')
18051812
})
18061813

18071814
it('should compile a file if it is written after the watcher starts', async () => {
1815+
console.log('starting should compile a file if it is written after the watcher starts')
18081816
await moveNextDist('.next', true)
18091817
const { watcher, isReady, nextBuild } = startWatching(process.cwd())
18101818
watchers.push(watcher)
@@ -1814,9 +1822,11 @@ describe('the dev middleware watcher', () => {
18141822
await writeFile(path.join(process.cwd(), 'middleware.ts'), middlewareSourceTs)
18151823
await isBuilt
18161824
expect(middlewareExists()).toBeTruthy()
1825+
console.log('done should compile a file if it is written after the watcher starts')
18171826
})
18181827

18191828
it('should remove the output if the middleware is removed after the watcher starts', async () => {
1829+
console.log('starting should remove the output if the middleware is removed after the watcher starts')
18201830
await moveNextDist('.next', true)
18211831
const { watcher, isReady, nextBuild } = startWatching(process.cwd())
18221832
watchers.push(watcher)
@@ -1830,9 +1840,11 @@ describe('the dev middleware watcher', () => {
18301840
await unlink(path.join(process.cwd(), 'middleware.ts'))
18311841
await isBuilt
18321842
expect(middlewareExists()).toBeFalsy()
1843+
console.log('done should remove the output if the middleware is removed after the watcher starts')
18331844
})
18341845

18351846
it('should remove the output if invalid middleware is written after the watcher starts', async () => {
1847+
console.log('starting should remove the output if invalid middleware is written after the watcher starts')
18361848
await moveNextDist('.next', true)
18371849
const { watcher, isReady, nextBuild } = startWatching(process.cwd())
18381850
watchers.push(watcher)
@@ -1846,9 +1858,13 @@ describe('the dev middleware watcher', () => {
18461858
await writeFile(path.join(process.cwd(), 'middleware.ts'), 'this is not valid middleware')
18471859
await isBuilt
18481860
expect(middlewareExists()).toBeFalsy()
1861+
console.log('done should remove the output if invalid middleware is written after the watcher starts')
18491862
})
18501863

18511864
it('should recompile the middleware if it is moved into the src directory after the watcher starts', async () => {
1865+
console.log(
1866+
'starting should recompile the middleware if it is moved into the src directory after the watcher starts',
1867+
)
18521868
await moveNextDist('.next', true)
18531869
const { watcher, isReady, nextBuild } = startWatching(process.cwd())
18541870
watchers.push(watcher)
@@ -1862,9 +1878,13 @@ describe('the dev middleware watcher', () => {
18621878
await move(path.join(process.cwd(), 'middleware.ts'), path.join(process.cwd(), 'src', 'middleware.ts'))
18631879
await isBuilt
18641880
expect(middlewareExists()).toBeTruthy()
1881+
console.log('done should recompile the middleware if it is moved into the src directory after the watcher starts')
18651882
})
18661883

18671884
it('should recompile the middleware if it is moved into the root directory after the watcher starts', async () => {
1885+
console.log(
1886+
'starting should recompile the middleware if it is moved into the root directory after the watcher starts',
1887+
)
18681888
await moveNextDist('.next', true)
18691889
const { watcher, isReady, nextBuild } = startWatching(process.cwd())
18701890
watchers.push(watcher)
@@ -1879,9 +1899,13 @@ describe('the dev middleware watcher', () => {
18791899
await move(path.join(process.cwd(), 'src', 'middleware.ts'), path.join(process.cwd(), 'middleware.ts'))
18801900
await isBuilt
18811901
expect(middlewareExists()).toBeTruthy()
1902+
console.log('done should recompile the middleware if it is moved into the root directory after the watcher starts')
18821903
})
18831904

18841905
it('should compile the middleware if invalid source is replaced with valid source after the watcher starts', async () => {
1906+
console.log(
1907+
'starting should compile the middleware if invalid source is replaced with valid source after the watcher starts',
1908+
)
18851909
await moveNextDist('.next', true)
18861910
const { watcher, isReady, nextBuild } = startWatching(process.cwd())
18871911
watchers.push(watcher)
@@ -1895,9 +1919,13 @@ describe('the dev middleware watcher', () => {
18951919
await writeFile(path.join(process.cwd(), 'middleware.ts'), middlewareSourceTs)
18961920
await isBuilt
18971921
expect(middlewareExists()).toBeTruthy()
1922+
console.log(
1923+
'done should compile the middleware if invalid source is replaced with valid source after the watcher starts',
1924+
)
18981925
})
18991926

19001927
it('should not compile middleware if more than one middleware file exists', async () => {
1928+
console.log('starting should not compile middleware if more than one middleware file exists')
19011929
await moveNextDist('.next', true)
19021930
const { watcher, isReady, nextBuild } = startWatching(process.cwd())
19031931
watchers.push(watcher)
@@ -1908,9 +1936,11 @@ describe('the dev middleware watcher', () => {
19081936
await writeFile(path.join(process.cwd(), 'middleware.js'), middlewareSourceJs)
19091937
await isBuilt
19101938
expect(middlewareExists()).toBeFalsy()
1939+
console.log('done should not compile middleware if more than one middleware file exists')
19111940
})
19121941

19131942
it('should not compile middleware if a second middleware file is added after the watcher starts', async () => {
1943+
console.log('starting should not compile middleware if a second middleware file is added after the watcher starts')
19141944
await moveNextDist('.next', true)
19151945
const { watcher, isReady, nextBuild } = startWatching(process.cwd())
19161946
watchers.push(watcher)
@@ -1924,9 +1954,11 @@ describe('the dev middleware watcher', () => {
19241954
await writeFile(path.join(process.cwd(), 'middleware.js'), middlewareSourceJs)
19251955
await isBuilt
19261956
expect(middlewareExists()).toBeFalsy()
1957+
console.log('done should not compile middleware if a second middleware file is added after the watcher starts')
19271958
})
19281959

19291960
it('should compile middleware if a second middleware file is removed after the watcher starts', async () => {
1961+
console.log('starting should compile middleware if a second middleware file is removed after the watcher starts')
19301962
await moveNextDist('.next', true)
19311963
const { watcher, isReady, nextBuild } = startWatching(process.cwd())
19321964
watchers.push(watcher)
@@ -1943,9 +1975,13 @@ describe('the dev middleware watcher', () => {
19431975
await unlink(path.join(process.cwd(), 'middleware.js'))
19441976
await isBuilt
19451977
expect(middlewareExists()).toBeTruthy()
1978+
console.log('done should compile middleware if a second middleware file is removed after the watcher starts')
19461979
})
19471980

19481981
it('should generate the correct output for each case when middleware is compiled, added, removed and for error states', async () => {
1982+
console.log(
1983+
'starting should generate the correct output for each case when middleware is compiled, added, removed and for error states',
1984+
)
19491985
await moveNextDist('.next', true)
19501986
const consoleLogSpy = jest.spyOn(console, 'log').mockImplementation(() => {})
19511987
const consoleErrorSpy = jest

0 commit comments

Comments
 (0)