@@ -142,6 +142,7 @@ describe.sequential("wrangler dev", () => {
142142 msw . resetHandlers ( ) ;
143143 spy . mockClear ( ) ;
144144 setSpy . mockClear ( ) ;
145+ logger . resetLoggerLevel ( ) ;
145146 } ) ;
146147
147148 async function runWranglerUntilConfig (
@@ -1211,7 +1212,7 @@ describe.sequential("wrangler dev", () => {
12111212 ) ;
12121213 expect ( std . out ) . toMatchInlineSnapshot ( `
12131214 "Your Worker and resources are simulated locally via Miniflare. For more information, see: https://developers.cloudflare.com/workers/testing/local-development.
1214-
1215+
12151216 Your worker has access to the following bindings:
12161217 - Durable Objects:
12171218 - NAME_1: CLASS_1
@@ -1304,7 +1305,7 @@ describe.sequential("wrangler dev", () => {
13041305 expect ( std . out ) . toMatchInlineSnapshot ( `
13051306 "Using vars defined in .dev.vars
13061307 Your Worker and resources are simulated locally via Miniflare. For more information, see: https://developers.cloudflare.com/workers/testing/local-development.
1307-
1308+
13081309 Your worker has access to the following bindings:
13091310 - Vars:
13101311 - VAR_1: \\"(hidden)\\"
@@ -1340,7 +1341,7 @@ describe.sequential("wrangler dev", () => {
13401341 expect ( std . out ) . toMatchInlineSnapshot ( `
13411342 "Using vars defined in .dev.vars.custom
13421343 Your Worker and resources are simulated locally via Miniflare. For more information, see: https://developers.cloudflare.com/workers/testing/local-development.
1343-
1344+
13441345 Your worker has access to the following bindings:
13451346 - Vars:
13461347 - CUSTOM_VAR: \\"(hidden)\\"
@@ -1356,64 +1357,6 @@ describe.sequential("wrangler dev", () => {
13561357 ) . rejects . toThrowErrorMatchingInlineSnapshot (
13571358 `[Error: Not enough arguments following: site]`
13581359 ) ;
1359-
1360- expect ( std ) . toMatchInlineSnapshot ( `
1361- Object {
1362- "debug": "",
1363- "err": "[31mX [41;31m[[41;97mERROR[41;31m][0m [1mNot enough arguments following: site[0m
1364-
1365- ",
1366- "info": "",
1367- "out": "
1368- wrangler dev [script]
1369-
1370- 👂 Start a local server for developing your Worker
1371-
1372- POSITIONALS
1373- script The path to an entry point for your Worker [string]
1374-
1375- GLOBAL FLAGS
1376- -c, --config Path to Wrangler configuration file [string]
1377- -e, --env Environment to use for operations, and for selecting .env and .dev.vars files [string]
1378- -h, --help Show help [boolean]
1379- -v, --version Show version number [boolean]
1380-
1381- OPTIONS
1382- --name Name of the Worker [string]
1383- --compatibility-date Date to use for compatibility checks [string]
1384- --compatibility-flags, --compatibility-flag Flags to use for compatibility checks [array]
1385- --latest Use the latest version of the Workers runtime [boolean] [default: true]
1386- --assets Static assets to be served. Replaces Workers Sites. [string]
1387- --no-bundle Skip internal build steps and directly deploy script [boolean] [default: false]
1388- --ip IP address to listen on [string]
1389- --port Port to listen on [number]
1390- --inspector-port Port for devtools to connect to [number]
1391- --routes, --route Routes to upload [array]
1392- --host Host to forward requests to, defaults to the zone of project [string]
1393- --local-protocol Protocol to listen to requests on, defaults to http. [choices: \\"http\\", \\"https\\"]
1394- --https-key-path Path to a custom certificate key [string]
1395- --https-cert-path Path to a custom certificate [string]
1396- --local-upstream Host to act as origin in local mode, defaults to dev.host or route [string]
1397- --upstream-protocol Protocol to forward requests to host on, defaults to https. [choices: \\"http\\", \\"https\\"]
1398- --var A key-value pair to be injected into the script as a variable [array]
1399- --define A key-value pair to be substituted in the script [array]
1400- --alias A module pair to be substituted in the script [array]
1401- --jsx-factory The function that is called for each JSX element [string]
1402- --jsx-fragment The function that is called for each JSX fragment [string]
1403- --tsconfig Path to a custom tsconfig.json file [string]
1404- -r, --remote Run on the global Cloudflare network with access to production resources [boolean] [default: false]
1405- --minify Minify the script [boolean]
1406- --node-compat Enable Node.js compatibility [boolean]
1407- --persist-to Specify directory to use for local persistence (defaults to .wrangler/state) [string]
1408- --live-reload Auto reload HTML pages when change is detected in local mode [boolean]
1409- --test-scheduled Test scheduled events by visiting /__scheduled in browser [boolean] [default: false]
1410- --log-level Specify logging level [choices: \\"debug\\", \\"info\\", \\"log\\", \\"warn\\", \\"error\\", \\"none\\"] [default: \\"log\\"]
1411- --show-interactive-dev-session Show interactive dev session (defaults to true if the terminal supports interactivity) [boolean]
1412- --experimental-vectorize-bind-to-prod Bind to production Vectorize indexes in local development mode [boolean] [default: false]
1413- --experimental-images-local-mode Use a local lower-fidelity implementation of the Images binding [boolean] [default: false]",
1414- "warn": "",
1415- }
1416- ` ) ;
14171360 } ) ;
14181361
14191362 it ( "should error if --legacy-assets and --site are used together" , async ( ) => {
@@ -1831,6 +1774,17 @@ describe.sequential("wrangler dev", () => {
18311774 "
18321775 ` ) ;
18331776 } ) ;
1777+
1778+ it ( "should also set log level using WRANGLER_LOG'" , async ( ) => {
1779+ fs . writeFileSync ( "index.js" , `export default {};` ) ;
1780+ vi . stubEnv ( "WRANGLER_LOG" , "none" ) ;
1781+ await runWranglerUntilConfig ( "dev index.js --inspect" ) ;
1782+ expect ( std . warn ) . toMatchInlineSnapshot ( `""` ) ;
1783+
1784+ vi . stubEnv ( "WRANGLER_LOG" , "debug" ) ;
1785+ await runWranglerUntilConfig ( "dev index.js" ) ;
1786+ expect ( std . debug ) . toContain ( ".env file not found at" ) ;
1787+ } ) ;
18341788 } ) ;
18351789
18361790 describe ( "--show-interactive-dev-session" , ( ) => {
@@ -1862,7 +1816,7 @@ describe.sequential("wrangler dev", () => {
18621816 await runWranglerUntilConfig ( "dev index.js" ) ;
18631817 expect ( std . out ) . toMatchInlineSnapshot ( `
18641818 "Your Worker and resources are simulated locally via Miniflare. For more information, see: https://developers.cloudflare.com/workers/testing/local-development.
1865-
1819+
18661820 Your worker has access to the following bindings:
18671821 - Services:
18681822 - WorkerA: A [not connected]
@@ -1885,7 +1839,7 @@ describe.sequential("wrangler dev", () => {
18851839 await runWranglerUntilConfig ( "dev index.js" ) ;
18861840 expect ( std . out ) . toMatchInlineSnapshot ( `
18871841 "Your Worker and resources are simulated locally via Miniflare. For more information, see: https://developers.cloudflare.com/workers/testing/local-development.
1888-
1842+
18891843 Your worker has access to the following bindings:
18901844 - Services:
18911845 - WorkerA: A [not connected]
@@ -1914,7 +1868,7 @@ describe.sequential("wrangler dev", () => {
19141868 expect ( std . out ) . toMatchInlineSnapshot ( `
19151869 "Using vars defined in .dev.vars
19161870 Your Worker and resources are simulated locally via Miniflare. For more information, see: https://developers.cloudflare.com/workers/testing/local-development.
1917-
1871+
19181872 Your worker has access to the following bindings:
19191873 - Vars:
19201874 - variable: 123
0 commit comments