Deno 2.5: Permissions in the config file Deno 2.5 introduces the ability to define permission sets directly in the `deno.json` config file, allowing users to pre-configure and reuse specific permission flags for different commands like `deno run` or `deno test`. The update also adds setup and teardown lifecycle APIs (`beforeAll`, `beforeEach`, `afterAll`, `afterEach`) to `Deno.test` for easier test management, alongside other improvements such as WebSocket headers and performance enhancements. To upgrade to Deno 2.5, run the following in your terminal: deno upgrade If Deno is not yet installed, run one of the following commands to install or learn how to install it here https://docs.deno.com/runtime/manual/getting started/installation . Using Shell macOS and Linux : curl -fsSL https://deno.land/install.sh | sh Using PowerShell Windows : iwr https://deno.land/install.ps1 -useb | iex What’s new in Deno 2.5 Permission sets in config permission-sets-in-config Setup and teardown APIs to setup-and-teardown-apis-to-denotest Deno.test WebSocket headers websocket-headers Runtime API for runtime-api-for-deno-bundle deno bundle HTML entrypoint support in html-entrypoint-support-in-deno-bundle deno bundle Permissions audit log permissions-audit-log deno run lists all tasks and scripts Simpler stdio from simpler-stdio-from-denochildprocess Deno.ChildProcess More consistent behavior for formatting options more-consistent-behavior-for-formatting-options Dependency management dependency-management Node.js nodejs-settimeout-and-setinterval-with---unstable-node-globals setTimeout and setInterval with --unstable-node-globals --watch environment variables with --env-file Set TCP backlog size to set-tcp-backlog-size-to-denoserve Deno.serve TSConfig compatibility for frameworks tsconfig-compatibility-for-frameworks Performance improvements performance-improvements Other features other-features V8 14.0 and TypeScript 5.9.2 v8-140-and-typescript-592 Acknowledgments acknowledgments Permission sets in config Oftentimes, granular permissions vary depending on context and subcommand: you may run deno main.ts with a certain set of permissions that differ from deno test or deno compile . To simplify managing permissions in these scenarios, we have added permission sets that you can set in your deno.json config file: { "permissions": { "process-data": { "read": "./data" , "write": "./data" } // ...more permissions can be defined here by name... }, "tasks": { "dev": "deno run -P=process-data main.ts" } } That way, you can run a command with pre-defined permission flags: Long deno run --permission-set=process-data main.ts Short deno run -P=process-data main.ts You can also set a default permission set, which can be used with -P with no argument: { "permissions": { "default": { "read": "./deno.json" , "env": true, "run": { "allow": "git" } } }, "tasks": { "dev": "deno run -P main.ts" } } Permissions can also be optionally specified within the test , bench , or compile keys: { "test": { "permissions": { "read": "./data" } } } When defined this way, you must pass the permission flag -P when running deno test , or you’ll receive an error: deno test error: Test permissions were found in the config file. Did you mean to run with -P ? at file:///Users/david/dev/scratch2/package-a/deno.json deno test -P ...runs... deno test --allow-read ...runs... deno test -A ...runs... For more information, please refer to our documentation https://docs.deno.com/runtime/fundamentals/configuration permissions . Setup and teardown APIs to Deno.test To make testing easier, we’ve added these new APIs to Deno.test https://docs.deno.com/runtime/fundamentals/testing/ to help perform setup and teardown for test cases: Deno.test.beforeAll Deno.test.beforeEach Deno.test.afterAll Deno.test.afterEach Here’s a concrete example showing how to set up a test database: python import sqlite from "node:sqlite"; import { assertEquals } from "jsr:@std/assert"; let testDb: sqlite.DatabaseSync; // Run once before all tests Deno.test.beforeAll = { testDb = new sqlite.DatabaseSync ":memory:" ; testDb.exec CREATE TABLE users id INTEGER PRIMARY KEY, name TEXT NOT NULL, email TEXT UNIQUE ; ; } ; // Run before each individual test Deno.test.beforeEach = { testDb.exec "DELETE FROM users" ; const insert = testDb.prepare "INSERT INTO users name, email VALUES ?, ? ", ; insert.run "Alice", "alice@example.com" ; insert.run "Bob", "bob@example.com" ; } ; // Run after each individual test Deno.test.afterEach = { // Clean up test data testDb.exec "DELETE FROM users" ; } ; // Run once after all tests Deno.test.afterAll = { testDb.close ; } ; Deno.test "should find user by email", = { const query = testDb.prepare "SELECT FROM users WHERE email = ?" ; const user = query.get "alice@example.com" ; assertEquals user?.name, "Alice" ; } ; Deno.test "should create new user", = { const insert = testDb.prepare "INSERT INTO users name, email VALUES ?, ? ", ; insert.run "Charlie", "charlie@example.com" ; const countQuery = testDb.prepare "SELECT COUNT as count FROM users" ; const result = countQuery.get ; assertEquals result .count, 3 ; // 2 from beforeEach + 1 new } ; For more information, please refer to our deno test documentation https://docs.deno.com/api/deno/testing test-hooks . WebSocket headers We’ve extended the WebSocket spec to allow for specifying custom headers when initiating a WebSocket connection: js const ws = new WebSocket "wss://api.example.com/socket", { headers: new Headers { "Authorization": Bearer ${token} , "X-Custom": "value", } , } ; This can be useful in scenarios when you need to authenticate, attach session state, or pass metadata right at the handshake stage, without leaking sensitive data in the URL or doing extra roundtrips. Keep in mind that this will not work in browsers. Runtime API for deno bundle In 2.4, we re-introduced deno bundle /v2.4 deno-bundle , which creates a single-file JavaScript file from JavaScript or TypeScript. In this release, we’ve added support for a runtime API, allowing you to programmatically bundle your client or server side JavaScript or TypeScript. For example, you have index.tsx : js import { render } from "npm:preact"; import "./styles.css"; const app =