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:
parent
ffc931aad1
commit
56c12a6f5f
@ -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:]...)
|
||||
|
@ -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 }
|
||||
|
Loading…
x
Reference in New Issue
Block a user