@@ -1764,7 +1764,7 @@ const wait = (seconds = 0.5) => new Promise((resolve) => setTimeout(resolve, sec
1764
1764
1765
1765
const middlewareExists = ( ) => existsSync ( resolve ( '.netlify' , 'middleware.js' ) )
1766
1766
1767
- describe . skip ( 'onPreDev' , ( ) => {
1767
+ describe ( 'onPreDev' , ( ) => {
1768
1768
let runtime
1769
1769
beforeAll ( async ( ) => {
1770
1770
runtime = await nextRuntimeFactory ( { } , { events : new Set ( [ 'onPreDev' ] ) } )
@@ -1786,25 +1786,33 @@ describe.skip('onPreDev', () => {
1786
1786
} )
1787
1787
} )
1788
1788
1789
- describe ( 'the dev middleware watcher' , ( ) => {
1789
+ fdescribe ( 'the dev middleware watcher' , ( ) => {
1790
1790
const watchers = [ ]
1791
1791
1792
1792
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
+ )
1794
1799
watchers . length = 0
1795
1800
} )
1796
1801
1797
1802
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' )
1798
1804
await moveNextDist ( '.next' , true )
1799
1805
await writeFile ( path . join ( process . cwd ( ) , 'middleware.ts' ) , middlewareSourceTs )
1800
1806
expect ( middlewareExists ( ) ) . toBeFalsy ( )
1801
1807
const { watcher, isReady } = startWatching ( process . cwd ( ) )
1802
1808
watchers . push ( watcher )
1803
1809
await isReady
1804
1810
expect ( middlewareExists ( ) ) . toBeTruthy ( )
1811
+ console . log ( 'done should compile a middleware file and then exit when killed' )
1805
1812
} )
1806
1813
1807
1814
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' )
1808
1816
await moveNextDist ( '.next' , true )
1809
1817
const { watcher, isReady, nextBuild } = startWatching ( process . cwd ( ) )
1810
1818
watchers . push ( watcher )
@@ -1814,9 +1822,11 @@ describe('the dev middleware watcher', () => {
1814
1822
await writeFile ( path . join ( process . cwd ( ) , 'middleware.ts' ) , middlewareSourceTs )
1815
1823
await isBuilt
1816
1824
expect ( middlewareExists ( ) ) . toBeTruthy ( )
1825
+ console . log ( 'done should compile a file if it is written after the watcher starts' )
1817
1826
} )
1818
1827
1819
1828
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' )
1820
1830
await moveNextDist ( '.next' , true )
1821
1831
const { watcher, isReady, nextBuild } = startWatching ( process . cwd ( ) )
1822
1832
watchers . push ( watcher )
@@ -1830,9 +1840,11 @@ describe('the dev middleware watcher', () => {
1830
1840
await unlink ( path . join ( process . cwd ( ) , 'middleware.ts' ) )
1831
1841
await isBuilt
1832
1842
expect ( middlewareExists ( ) ) . toBeFalsy ( )
1843
+ console . log ( 'done should remove the output if the middleware is removed after the watcher starts' )
1833
1844
} )
1834
1845
1835
1846
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' )
1836
1848
await moveNextDist ( '.next' , true )
1837
1849
const { watcher, isReady, nextBuild } = startWatching ( process . cwd ( ) )
1838
1850
watchers . push ( watcher )
@@ -1846,9 +1858,13 @@ describe('the dev middleware watcher', () => {
1846
1858
await writeFile ( path . join ( process . cwd ( ) , 'middleware.ts' ) , 'this is not valid middleware' )
1847
1859
await isBuilt
1848
1860
expect ( middlewareExists ( ) ) . toBeFalsy ( )
1861
+ console . log ( 'done should remove the output if invalid middleware is written after the watcher starts' )
1849
1862
} )
1850
1863
1851
1864
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
+ )
1852
1868
await moveNextDist ( '.next' , true )
1853
1869
const { watcher, isReady, nextBuild } = startWatching ( process . cwd ( ) )
1854
1870
watchers . push ( watcher )
@@ -1862,9 +1878,13 @@ describe('the dev middleware watcher', () => {
1862
1878
await move ( path . join ( process . cwd ( ) , 'middleware.ts' ) , path . join ( process . cwd ( ) , 'src' , 'middleware.ts' ) )
1863
1879
await isBuilt
1864
1880
expect ( middlewareExists ( ) ) . toBeTruthy ( )
1881
+ console . log ( 'done should recompile the middleware if it is moved into the src directory after the watcher starts' )
1865
1882
} )
1866
1883
1867
1884
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
+ )
1868
1888
await moveNextDist ( '.next' , true )
1869
1889
const { watcher, isReady, nextBuild } = startWatching ( process . cwd ( ) )
1870
1890
watchers . push ( watcher )
@@ -1879,9 +1899,13 @@ describe('the dev middleware watcher', () => {
1879
1899
await move ( path . join ( process . cwd ( ) , 'src' , 'middleware.ts' ) , path . join ( process . cwd ( ) , 'middleware.ts' ) )
1880
1900
await isBuilt
1881
1901
expect ( middlewareExists ( ) ) . toBeTruthy ( )
1902
+ console . log ( 'done should recompile the middleware if it is moved into the root directory after the watcher starts' )
1882
1903
} )
1883
1904
1884
1905
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
+ )
1885
1909
await moveNextDist ( '.next' , true )
1886
1910
const { watcher, isReady, nextBuild } = startWatching ( process . cwd ( ) )
1887
1911
watchers . push ( watcher )
@@ -1895,9 +1919,13 @@ describe('the dev middleware watcher', () => {
1895
1919
await writeFile ( path . join ( process . cwd ( ) , 'middleware.ts' ) , middlewareSourceTs )
1896
1920
await isBuilt
1897
1921
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
+ )
1898
1925
} )
1899
1926
1900
1927
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' )
1901
1929
await moveNextDist ( '.next' , true )
1902
1930
const { watcher, isReady, nextBuild } = startWatching ( process . cwd ( ) )
1903
1931
watchers . push ( watcher )
@@ -1908,9 +1936,11 @@ describe('the dev middleware watcher', () => {
1908
1936
await writeFile ( path . join ( process . cwd ( ) , 'middleware.js' ) , middlewareSourceJs )
1909
1937
await isBuilt
1910
1938
expect ( middlewareExists ( ) ) . toBeFalsy ( )
1939
+ console . log ( 'done should not compile middleware if more than one middleware file exists' )
1911
1940
} )
1912
1941
1913
1942
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' )
1914
1944
await moveNextDist ( '.next' , true )
1915
1945
const { watcher, isReady, nextBuild } = startWatching ( process . cwd ( ) )
1916
1946
watchers . push ( watcher )
@@ -1924,9 +1954,11 @@ describe('the dev middleware watcher', () => {
1924
1954
await writeFile ( path . join ( process . cwd ( ) , 'middleware.js' ) , middlewareSourceJs )
1925
1955
await isBuilt
1926
1956
expect ( middlewareExists ( ) ) . toBeFalsy ( )
1957
+ console . log ( 'done should not compile middleware if a second middleware file is added after the watcher starts' )
1927
1958
} )
1928
1959
1929
1960
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' )
1930
1962
await moveNextDist ( '.next' , true )
1931
1963
const { watcher, isReady, nextBuild } = startWatching ( process . cwd ( ) )
1932
1964
watchers . push ( watcher )
@@ -1943,9 +1975,13 @@ describe('the dev middleware watcher', () => {
1943
1975
await unlink ( path . join ( process . cwd ( ) , 'middleware.js' ) )
1944
1976
await isBuilt
1945
1977
expect ( middlewareExists ( ) ) . toBeTruthy ( )
1978
+ console . log ( 'done should compile middleware if a second middleware file is removed after the watcher starts' )
1946
1979
} )
1947
1980
1948
1981
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
+ )
1949
1985
await moveNextDist ( '.next' , true )
1950
1986
const consoleLogSpy = jest . spyOn ( console , 'log' ) . mockImplementation ( ( ) => { } )
1951
1987
const consoleErrorSpy = jest
0 commit comments