@@ -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' ] ) } )
@@ -1795,16 +1795,19 @@ describe('the dev middleware watcher', () => {
1795
1795
} )
1796
1796
1797
1797
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' )
1798
1799
await moveNextDist ( '.next' , true )
1799
1800
await writeFile ( path . join ( process . cwd ( ) , 'middleware.ts' ) , middlewareSourceTs )
1800
1801
expect ( middlewareExists ( ) ) . toBeFalsy ( )
1801
1802
const { watcher, isReady } = startWatching ( process . cwd ( ) )
1802
1803
watchers . push ( watcher )
1803
1804
await isReady
1804
1805
expect ( middlewareExists ( ) ) . toBeTruthy ( )
1806
+ console . log ( 'done should compile a middleware file and then exit when killed' )
1805
1807
} )
1806
1808
1807
1809
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' )
1808
1811
await moveNextDist ( '.next' , true )
1809
1812
const { watcher, isReady, nextBuild } = startWatching ( process . cwd ( ) )
1810
1813
watchers . push ( watcher )
@@ -1814,9 +1817,11 @@ describe('the dev middleware watcher', () => {
1814
1817
await writeFile ( path . join ( process . cwd ( ) , 'middleware.ts' ) , middlewareSourceTs )
1815
1818
await isBuilt
1816
1819
expect ( middlewareExists ( ) ) . toBeTruthy ( )
1820
+ console . log ( 'done should compile a file if it is written after the watcher starts' )
1817
1821
} )
1818
1822
1819
1823
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' )
1820
1825
await moveNextDist ( '.next' , true )
1821
1826
const { watcher, isReady, nextBuild } = startWatching ( process . cwd ( ) )
1822
1827
watchers . push ( watcher )
@@ -1830,9 +1835,11 @@ describe('the dev middleware watcher', () => {
1830
1835
await unlink ( path . join ( process . cwd ( ) , 'middleware.ts' ) )
1831
1836
await isBuilt
1832
1837
expect ( middlewareExists ( ) ) . toBeFalsy ( )
1838
+ console . log ( 'done should remove the output if the middleware is removed after the watcher starts' )
1833
1839
} )
1834
1840
1835
1841
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' )
1836
1843
await moveNextDist ( '.next' , true )
1837
1844
const { watcher, isReady, nextBuild } = startWatching ( process . cwd ( ) )
1838
1845
watchers . push ( watcher )
@@ -1846,9 +1853,13 @@ describe('the dev middleware watcher', () => {
1846
1853
await writeFile ( path . join ( process . cwd ( ) , 'middleware.ts' ) , 'this is not valid middleware' )
1847
1854
await isBuilt
1848
1855
expect ( middlewareExists ( ) ) . toBeFalsy ( )
1856
+ console . log ( 'done should remove the output if invalid middleware is written after the watcher starts' )
1849
1857
} )
1850
1858
1851
1859
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
+ )
1852
1863
await moveNextDist ( '.next' , true )
1853
1864
const { watcher, isReady, nextBuild } = startWatching ( process . cwd ( ) )
1854
1865
watchers . push ( watcher )
@@ -1862,9 +1873,13 @@ describe('the dev middleware watcher', () => {
1862
1873
await move ( path . join ( process . cwd ( ) , 'middleware.ts' ) , path . join ( process . cwd ( ) , 'src' , 'middleware.ts' ) )
1863
1874
await isBuilt
1864
1875
expect ( middlewareExists ( ) ) . toBeTruthy ( )
1876
+ console . log ( 'done should recompile the middleware if it is moved into the src directory after the watcher starts' )
1865
1877
} )
1866
1878
1867
1879
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
+ )
1868
1883
await moveNextDist ( '.next' , true )
1869
1884
const { watcher, isReady, nextBuild } = startWatching ( process . cwd ( ) )
1870
1885
watchers . push ( watcher )
@@ -1879,9 +1894,13 @@ describe('the dev middleware watcher', () => {
1879
1894
await move ( path . join ( process . cwd ( ) , 'src' , 'middleware.ts' ) , path . join ( process . cwd ( ) , 'middleware.ts' ) )
1880
1895
await isBuilt
1881
1896
expect ( middlewareExists ( ) ) . toBeTruthy ( )
1897
+ console . log ( 'done should recompile the middleware if it is moved into the root directory after the watcher starts' )
1882
1898
} )
1883
1899
1884
1900
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
+ )
1885
1904
await moveNextDist ( '.next' , true )
1886
1905
const { watcher, isReady, nextBuild } = startWatching ( process . cwd ( ) )
1887
1906
watchers . push ( watcher )
@@ -1895,9 +1914,13 @@ describe('the dev middleware watcher', () => {
1895
1914
await writeFile ( path . join ( process . cwd ( ) , 'middleware.ts' ) , middlewareSourceTs )
1896
1915
await isBuilt
1897
1916
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
+ )
1898
1920
} )
1899
1921
1900
1922
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' )
1901
1924
await moveNextDist ( '.next' , true )
1902
1925
const { watcher, isReady, nextBuild } = startWatching ( process . cwd ( ) )
1903
1926
watchers . push ( watcher )
@@ -1908,9 +1931,11 @@ describe('the dev middleware watcher', () => {
1908
1931
await writeFile ( path . join ( process . cwd ( ) , 'middleware.js' ) , middlewareSourceJs )
1909
1932
await isBuilt
1910
1933
expect ( middlewareExists ( ) ) . toBeFalsy ( )
1934
+ console . log ( 'done should not compile middleware if more than one middleware file exists' )
1911
1935
} )
1912
1936
1913
1937
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' )
1914
1939
await moveNextDist ( '.next' , true )
1915
1940
const { watcher, isReady, nextBuild } = startWatching ( process . cwd ( ) )
1916
1941
watchers . push ( watcher )
@@ -1924,9 +1949,11 @@ describe('the dev middleware watcher', () => {
1924
1949
await writeFile ( path . join ( process . cwd ( ) , 'middleware.js' ) , middlewareSourceJs )
1925
1950
await isBuilt
1926
1951
expect ( middlewareExists ( ) ) . toBeFalsy ( )
1952
+ console . log ( 'done should not compile middleware if a second middleware file is added after the watcher starts' )
1927
1953
} )
1928
1954
1929
1955
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' )
1930
1957
await moveNextDist ( '.next' , true )
1931
1958
const { watcher, isReady, nextBuild } = startWatching ( process . cwd ( ) )
1932
1959
watchers . push ( watcher )
@@ -1943,9 +1970,13 @@ describe('the dev middleware watcher', () => {
1943
1970
await unlink ( path . join ( process . cwd ( ) , 'middleware.js' ) )
1944
1971
await isBuilt
1945
1972
expect ( middlewareExists ( ) ) . toBeTruthy ( )
1973
+ console . log ( 'done should compile middleware if a second middleware file is removed after the watcher starts' )
1946
1974
} )
1947
1975
1948
1976
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
+ )
1949
1980
await moveNextDist ( '.next' , true )
1950
1981
const consoleLogSpy = jest . spyOn ( console , 'log' ) . mockImplementation ( ( ) => { } )
1951
1982
const consoleErrorSpy = jest
0 commit comments