File
Blob: samples/unit-tests/config.capnp
| 1 | # This is an example configuration for running unit tests. |
| 2 | # |
| 3 | # (If you're not already familiar with the basic config format, check out the hello world example |
| 4 | # first.) |
| 5 | # |
| 6 | # Most projects will probably use some sort of script or tooling to auto-generate this |
| 7 | # configuration (such as Wrangler), and instead focus on the contents of the JavaScript file. |
| 8 | # |
| 9 | # To run the tests, do: |
| 10 | # |
| 11 | # workerd test config.capnp |
| 12 | |
| 13 | using Workerd = import "/workerd/workerd.capnp"; |
| 14 | |
| 15 | const unitTests :Workerd.Config = ( |
| 16 | services = [ |
| 17 | # Define the service to be tested. |
| 18 | (name = "main", worker = .testWorker), |
| 19 | |
| 20 | # Not required, but we can redefine the special "internet" service so that it disallows any |
| 21 | # outgoing connections. This prohibits the test from talking to the network. |
| 22 | (name = "internet", network = (allow = [])) |
| 23 | ], |
| 24 | |
| 25 | # For running tests, we do not need to define any sockets, since tests do not accept incoming |
| 26 | # connections. |
| 27 | ); |
| 28 | |
| 29 | const testWorker :Workerd.Worker = ( |
| 30 | # Just a regular old worker definition. |
| 31 | modules = [ |
| 32 | (name = "worker", esModule = embed "worker.js") |
| 33 | ], |
| 34 | compatibilityDate = "2023-02-28", |
| 35 | ); |