1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-01-20 05:19:40 +02:00

feat(karma): add verbose logging for karma (#4340)

* feat(karma): add verbose logging for karma

* Update karmaExecuteTests_test.go

* Update karmaExecuteTests.go

* Update karmaExecuteTests.go

* fmt

* correct test case
This commit is contained in:
Christopher Fenner 2023-05-04 09:38:23 +02:00 committed by GitHub
parent ffc931aad1
commit 56c12a6f5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View File

@ -22,6 +22,10 @@ func runKarma(config karmaExecuteTestsOptions, command command.ExecRunner) {
runCommandTokens := tokenize(config.RunCommand)
modulePaths := config.Modules
if GeneralConfig.Verbose {
runCommandTokens = append(runCommandTokens, "--", "--log-level", "DEBUG")
}
for _, module := range modulePaths {
command.SetDir(module)
err := command.RunExecutable(installCommandTokens[0], installCommandTokens[1:]...)

View File

@ -28,6 +28,19 @@ func TestRunKarma(t *testing.T) {
})
t.Run("success case - verbose logging", func(t *testing.T) {
GeneralConfig.Verbose = true
defer func() { GeneralConfig.Verbose = false }()
opts := karmaExecuteTestsOptions{Modules: []string{"./test"}, InstallCommand: "npm install test", RunCommand: "npm run test"}
e := mock.ExecMockRunner{}
runKarma(opts, &e)
assert.Equal(t, "./test", e.Dir[1], "run command dir incorrect")
assert.Equal(t, mock.ExecCall{Exec: "npm", Params: []string{"run", "test", "--", "--log-level", "DEBUG"}}, e.Calls[1], "run command/params incorrect")
})
t.Run("error case install command", func(t *testing.T) {
var hasFailed bool
log.Entry().Logger.ExitFunc = func(int) { hasFailed = true }