Skip to content

Commit

Permalink
fix(review): align tables with other documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
hampuslavin committed Oct 30, 2024
1 parent 0884efb commit f9432a6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 37 deletions.
48 changes: 12 additions & 36 deletions docs/06-concepts/18-testing/02-the-basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

The `withServerpod` helper provides a `sessionBuilder` that helps with setting up different scenarios for tests. To modify the session builder's properties, call its `copyWith` method. It takes the following named parameters:

|Property|Type|Default|Description|
|:-----|:-----|:---:|:-----|
|`authentication`|`AuthenticationOverride?`|`AuthenticationOverride.unauthenticated()`|See section [Setting authenticated state](#setting-authenticated-state).|
|`enableLogging`|`bool?`|`false`|Whether logging is turned on for the session.|
|Property|Description|Default|
|:---|:---|:---:|
|`authentication`|See section [Setting authenticated state](#setting-authenticated-state).|`AuthenticationOverride.unauthenticated()`|
|`enableLogging`|Whether logging is turned on for the session.|`false`|

The `copyWith` method creates a new unique session builder with the provided properties. This can then be used in endpoint calls (see section [Setting authenticated state](#setting-authenticated-state) for an example).

Expand Down Expand Up @@ -125,23 +125,15 @@ withServerpod(

The following optional configuration options are available to pass as a second argument to `withServerpod`:

|Property|Type|Default|
|Property|Description|Default|
|:-----|:-----|:---:|
|`applyMigrations`|`bool?`|`true`|
|`enableSessionLogging`|`bool?`|`false`|
|`rollbackDatabase`|`RollbackDatabase?`|`RollbackDatabase.afterEach`|
|`runMode`|`String?`|`ServerpodRunmode.test`|
|`serverpodLoggingMode`|`ServerpodLoggingMode?`|`ServerpodLoggingMode.normal`|
|`serverpodStartTimeout`|`Duration?`|`Duration(seconds: 30)`|
|`testGroupTagsOverride`|`List<String>?`|`['integration']`|

### `applyMigrations`

Whether pending migrations should be applied when starting Serverpod. Defaults to `true`.

### `enableSessionLogging`

Whether session logging should be enabled. Defaults to `false`.
|`applyMigrations`|Whether pending migrations should be applied when starting Serverpod.|`true`|
|`enableSessionLogging`|Whether session logging should be enabled.|`false`|
|`rollbackDatabase`|Options for when to rollback the database during the test lifecycle (or disable it).|`RollbackDatabase.afterEach`|
|`runMode`|The run mode that Serverpod should be running in.|`ServerpodRunmode.test`|
|`serverpodLoggingMode`|The logging mode used when creating Serverpod.|`ServerpodLoggingMode.normal`|
|`serverpodStartTimeout`|The timeout to use when starting Serverpod, which connects to the database among other things. Defaults to `Duration(seconds: 30)`.|`Duration(seconds: 30)`|
|`testGroupTagsOverride`|By default Serverpod test tools tags the `withServerpod` test group with `"integration"`. This is to provide a simple way to only run unit or integration tests. This property allows this tag to be overridden to something else. Defaults to `['integration']`.|`['integration']`|

### `rollbackDatabase` {#rollback-database-configuration}

Expand Down Expand Up @@ -234,22 +226,6 @@ await transactionFuture;

In production, the transaction call will throw if any database exception happened during its execution, _even_ if the exception was first caught inside the transaction. However, in the test tools this will not throw an exception due to how the nested transactions are emulated. Quelling exceptions like this is not best practise, but if the code under test does this setting `rollbackDatabase` to `RollbackDatabse.disabled` will ensure the code behaves like in production.

### `runMode`

The run mode that Serverpod should be running in. Defaults to `test`.

### `serverpodLoggingMode`

The logging mode used when creating Serverpod. Defaults to `ServerpodLoggingMode.normal`.

### `serverpodStartTimeout`

The timeout to use when starting Serverpod, which connects to the database among other things. Defaults to `Duration(seconds: 30)`.

### `testGroupTagsOverride` {#test-group-tags-override-configuration}

By default Serverpod test tools tags the `withServerpod` test group with `"integration"`. This is to provide a simple way to only run unit or integration tests. This property allows this tag to be overridden to something else. Defaults to `['integration']`.

## Test exceptions

The following exceptions are exported from the generated test tools file and can be thrown by the test tools in various scenarios, see below.
Expand Down
2 changes: 1 addition & 1 deletion docs/06-concepts/18-testing/03-advanced-examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dart test -t integration
dart test -x integration
```

To change the name of this tag, see the [`testGroupTagsOverride`](the-basics#test-group-tags-override-configuration) configuration option.
To change the name of this tag, see the [`testGroupTagsOverride`](the-basics#configuration) configuration option.

## Test business logic that depends on `Session`

Expand Down

0 comments on commit f9432a6

Please sign in to comment.