Skip to content

[Bug]: bc-replay fails on linux/ubuntu #2030

@ChrisBlankDe

Description

@ChrisBlankDe

AL-Go version

8.0

Describe the issue

When running page scripting tests on ubuntu the bc-replay tool fails

Expected behavior

The tool should work exactly the same under Ubuntu as it does under Windows.

Steps to reproduce

My Testing Script

npm i @microsoft/bc-replay@0.1.67 --save
export REPLAYUSER="ChrisBlankDe"
export REPLAYPWD="***"
npx playwright install-deps
npx replay *.yml -StartAddress https://***/?tenant=default -Authentication UserPassword -UserNameKey REPLAYUSER -PasswordKey REPLAYPWD

Return of npx replay

PS: PlayerSpec=#!/usr/bin/env pwsh
#--------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#--------------------------------------------------------------------------

<#
.SYNOPSIS
Runs the test recordings using the Playwright test runner against an Business Central environment.
.DESCRIPTION
This script runs the test recordings using the Playwright test runner against an Business Central environment.

.PARAMETER Tests
(mandatory) A file globber pattern of the tests that should be run.
.PARAMETER StartAddress
(mandatory) The Business Central URL to run the tests against.
.PARAMETER Headed
(optional) Run the tests in headed mode.
.PARAMETER ResultDir
(optional) The directory where the test results should be saved. Defaults to the current working directory. It does not support multi-factor authentication. Use an account that requires only a username and password to sign in for your tests.
.PARAMETER Authentication
(optional) The authentication method to use. Valid values are 'Windows', 'AAD', 'UserPassword'. Defaults to 'Windows'.
.PARAMETER UserNameKey
(optional) The environment variable that contains the username to use for authentication. 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 env variables contains these.
.PARAMETER PasswordKey
(optional) The environment variable that contains the password to use for authentication. 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 env variables contains these.
#>
[CmdletBinding()]
param (
    [Parameter(Mandatory=$true, Position=0)]
    [string]
    $Tests,

    [Parameter(Mandatory=$true)]
    [string]
    $StartAddress,
    
    [Parameter()]
    [switch]
    $Headed,

    [Parameter()]
    [string]
    $ResultDir,

    [Parameter()]
    [string]
    [ValidateSet('Windows','AAD','UserPassword')]
    $Authentication,

    [Parameter()]
    [string]
    $UserNameKey,

    [Parameter()]
    [string]
    $PasswordKey
)

$PSScriptRoot = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition

$WorkingDir = Get-Location
$OutputDir = Join-Path -Path $WorkingDir -ChildPath "test-results"

${env:bc-player-testDir} = $PSScriptRoot + "/player"
${env:bc-player-workingDir} = $WorkingDir
${env:bc-player-tests} = $Tests

if($ResultDir) {
    ${env:bc-player-resultDir} = Resolve-Path $ResultDir
}

if($StartAddress) {
    ${env:bc-player-startAddress} = $StartAddress
}

if($Authentication) {
    ${env:bc-player-auth} = $Authentication
}

if($UserNameKey) {
    if(!(Get-Item env:$UserNameKey -ErrorAction Ignore).Value) {
        throw "The specified UserNameKey '$($UserNameKey)' environment variable hos not been set."
    }
    ${env:bc-player-username-key} = $UserNameKey
}

if($PasswordKey) {
    if(!(Get-Item env:$PasswordKey -ErrorAction Ignore).Value) {
        throw "The specified PasswordKey '$($PasswordKey)' environment variable hos not been set."
    }
    ${env:bc-player-password-key} = $PasswordKey
}

$PlayerSpec = (Join-Path $PSScriptRoot "player/dist/player.spec.js").Replace('/', '/')
$ConfigFile = (Join-Path $PSScriptRoot "player/dist/playwright.config.js").Replace('/', '/player/dist/player.spec.js
PS: ConfigFile=#!/usr/bin/env pwsh
#--------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#--------------------------------------------------------------------------

<#
.SYNOPSIS
Runs the test recordings using the Playwright test runner against an Business Central environment.
.DESCRIPTION
This script runs the test recordings using the Playwright test runner against an Business Central environment.

.PARAMETER Tests
(mandatory) A file globber pattern of the tests that should be run.
.PARAMETER StartAddress
(mandatory) The Business Central URL to run the tests against.
.PARAMETER Headed
(optional) Run the tests in headed mode.
.PARAMETER ResultDir
(optional) The directory where the test results should be saved. Defaults to the current working directory. It does not support multi-factor authentication. Use an account that requires only a username and password to sign in for your tests.
.PARAMETER Authentication
(optional) The authentication method to use. Valid values are 'Windows', 'AAD', 'UserPassword'. Defaults to 'Windows'.
.PARAMETER UserNameKey
(optional) The environment variable that contains the username to use for authentication. 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 env variables contains these.
.PARAMETER PasswordKey
(optional) The environment variable that contains the password to use for authentication. 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 env variables contains these.
#>
[CmdletBinding()]
param (
    [Parameter(Mandatory=$true, Position=0)]
    [string]
    $Tests,

    [Parameter(Mandatory=$true)]
    [string]
    $StartAddress,
    
    [Parameter()]
    [switch]
    $Headed,

    [Parameter()]
    [string]
    $ResultDir,

    [Parameter()]
    [string]
    [ValidateSet('Windows','AAD','UserPassword')]
    $Authentication,

    [Parameter()]
    [string]
    $UserNameKey,

    [Parameter()]
    [string]
    $PasswordKey
)

$PSScriptRoot = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition

$WorkingDir = Get-Location
$OutputDir = Join-Path -Path $WorkingDir -ChildPath "test-results"

${env:bc-player-testDir} = $PSScriptRoot + "/player"
${env:bc-player-workingDir} = $WorkingDir
${env:bc-player-tests} = $Tests

if($ResultDir) {
    ${env:bc-player-resultDir} = Resolve-Path $ResultDir
}

if($StartAddress) {
    ${env:bc-player-startAddress} = $StartAddress
}

if($Authentication) {
    ${env:bc-player-auth} = $Authentication
}

if($UserNameKey) {
    if(!(Get-Item env:$UserNameKey -ErrorAction Ignore).Value) {
        throw "The specified UserNameKey '$($UserNameKey)' environment variable hos not been set."
    }
    ${env:bc-player-username-key} = $UserNameKey
}

if($PasswordKey) {
    if(!(Get-Item env:$PasswordKey -ErrorAction Ignore).Value) {
        throw "The specified PasswordKey '$($PasswordKey)' environment variable hos not been set."
    }
    ${env:bc-player-password-key} = $PasswordKey
}

$PlayerSpec = (Join-Path $PSScriptRoot "player/dist/player.spec.js").Replace('/', '/')
$ConfigFile = (Join-Path $PSScriptRoot "player/dist/playwright.config.js").Replace('/', '/player/dist/playwright.config.js
Error: /workspaces/TryALReplay/#!/usr/bin/env pwsh
#--------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
#--------------------------------------------------------------------------

<#
.SYNOPSIS
Runs the test recordings using the Playwright test runner against an Business Central environment.
.DESCRIPTION
This script runs the test recordings using the Playwright test runner against an Business Central environment.

.PARAMETER Tests
(mandatory) A file globber pattern of the tests that should be run.
.PARAMETER StartAddress
(mandatory) The Business Central URL to run the tests against.
.PARAMETER Headed
(optional) Run the tests in headed mode.
.PARAMETER ResultDir
(optional) The directory where the test results should be saved. Defaults to the current working directory. It does not support multi-factor authentication. Use an account that requires only a username and password to sign in for your tests.
.PARAMETER Authentication
(optional) The authentication method to use. Valid values are 'Windows', 'AAD', 'UserPassword'. Defaults to 'Windows'.
.PARAMETER UserNameKey
(optional) The environment variable that contains the username to use for authentication. 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 env variables contains these.
.PARAMETER PasswordKey
(optional) The environment variable that contains the password to use for authentication. 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 env variables contains these.
#>
[CmdletBinding()]
param (
    [Parameter(Mandatory=$true, Position=0)]
    [string]
    $Tests,

    [Parameter(Mandatory=$true)]
    [string]
    $StartAddress,
    
    [Parameter()]
    [switch]
    $Headed,

    [Parameter()]
    [string]
    $ResultDir,

    [Parameter()]
    [string]
    [ValidateSet('Windows','AAD','UserPassword')]
    $Authentication,

    [Parameter()]
    [string]
    $UserNameKey,

    [Parameter()]
    [string]
    $PasswordKey
)

$PSScriptRoot = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition

$WorkingDir = Get-Location
$OutputDir = Join-Path -Path $WorkingDir -ChildPath "test-results"

${env:bc-player-testDir} = $PSScriptRoot + "/player"
${env:bc-player-workingDir} = $WorkingDir
${env:bc-player-tests} = $Tests

if($ResultDir) {
    ${env:bc-player-resultDir} = Resolve-Path $ResultDir
}

if($StartAddress) {
    ${env:bc-player-startAddress} = $StartAddress
}

if($Authentication) {
    ${env:bc-player-auth} = $Authentication
}

if($UserNameKey) {
    if(!(Get-Item env:$UserNameKey -ErrorAction Ignore).Value) {
        throw "The specified UserNameKey '$($UserNameKey)' environment variable hos not been set."
    }
    ${env:bc-player-username-key} = $UserNameKey
}

if($PasswordKey) {
    if(!(Get-Item env:$PasswordKey -ErrorAction Ignore).Value) {
        throw "The specified PasswordKey '$($PasswordKey)' environment variable hos not been set."
    }
    ${env:bc-player-password-key} = $PasswordKey
}

$PlayerSpec = (Join-Path $PSScriptRoot "player/dist/player.spec.js").Replace('/', '/')
$ConfigFile = (Join-Path $PSScriptRoot "player/dist/playwright.config.js").Replace('/', '/player/dist/playwright.config.js does not exist
    at resolveConfigFile (/workspaces/TryALReplay/node_modules/playwright/lib/common/configLoader.js:259:52)
    at resolveConfigLocation (/workspaces/TryALReplay/node_modules/playwright/lib/common/configLoader.js:243:30)
    at loadConfigFromFileRestartIfNeeded (/workspaces/TryALReplay/node_modules/playwright/lib/common/configLoader.js:271:20)
    at runTests (/workspaces/TryALReplay/node_modules/playwright/lib/program.js:199:76)
    at async t.<anonymous> (/workspaces/TryALReplay/node_modules/playwright/lib/program.js:54:7)
Exception: 
Line |
 119 |  …  ($TestPass -ne "True") {throw "One or more test recordings failed."}
     |                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | One or more test recordings failed.

Additional context (logs, screenshots, etc.)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Unrelated to AL-GoThis issue is unrelated to AL-GobugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions