
# BC replay

BC replay is an npm command used to replay Business Central recordings.

### Requirements
The following things must be available to use this command:
- NodeJs minimum version 16.14.0
- PowerShell version 7+

### Getting started
Create a new folder and `cd` to it.

#### Add `@microsoft/bc-replay` and install playwright
```
npm i @microsoft/bc-replay --save
```

Now add a folder to store some recordings, e.g. mkdir recordings and add some recording .yml files.

Then you can run any tests added to the recordings folder against Business Central web client instance:
```
npx replay .\recordings\*.yml -StartAddress http://localhost:8080/
```

## Parameters
```
npx replay
      [-Tests] <String>
      -StartAddress <String>
      [-Authentication Windows|AAD|UserPassword]
      [-UserNameKey <String>]
      [-PasswordKey <String>]
      [-MultiFactorType None|TOTP|Certificate]
      [-MultiFactorSecretKey <String>]
      [-Headed]
      [-UseServerReplay]
      [-ResultDir <String>]
```

#### -Tests
File glob pattern to select the tests recordings to run

#### -StartAddress
The url to the deployed web client.

#### -Authentication
The authentication to use against the web client. One of Windows, AAD, UserPassword. Windows is the default.
Multi-factor authentication is available only when set to AAD.

#### -UserNameKey & -PasswordKey
When -Authentication is set to AAD or UserPassword then a user name and password must be given. These must be transferred as environment variables and -UserNameKey and -PasswordKey are used to specify which environment variables contains these.

#### -MultiFactorType
Sets the multi-factor authentication mechanism. Valid options are None, TOTP, and Certificate. Defaults to None. This parameter can only be used together with `-Authentication AAD`. When `-UseServerReplay` is present, this value must remain `None`.

#### -MultiFactorSecretKey
The environment variable that stores the MFA secret referenced by `-MultiFactorType`. The environment variable must be set before invoking the command.
* For TOTP this must be the TOTP secret key.
* For Certificate this must hold the Base64-encoded PFX certificate.

#### -Headed
Will show the test running in the browsers.

#### -ResultDir
The directory to write the test results.