Skip to content

πŸ–οΈ There is no file exported to the host machine when the execution command fails.Β #8275

Closed

Description

@GeitRavi

What happened? What did you expect to happen?

We are trying to run the UI Playwright tests and export the test results to the host machine. This works fine when all tests pass. However, when there is a test failure, the container exits with error code 2 and does not export the test report.

func (m *Demo1) RunTest(ctx context.Context, source *dagger.Directory) *dagger.File {

        // Connect to the Dagger eng
        container := dag.Container().
                From("mcr.microsoft.com/playwright:v1.46.1-focal").
                WithDirectory("/app", source).
                WithWorkdir("/app").
                WithEnvVariable("npm_config_yes", "true").
                WithExec([]string{"npm", "install", "-g", "[email protected]"}).
                WithExec([]string{"npm", "install", "@playwright/test"}).
                WithExec([]string{"npx", "playwright", "test"})

        _,err := container.Stdout(ctx)
        if err != nil {
        return container.Directory("/app").File("results.xml")
        }
		return container.Directory("/app").File("results.xml")
		
}

Is there a way to export the report in case of failure as well.Thanks

Activity

  1. jedevc commented on Sep 3, 2024

    @jedevc
    Contributor

    You can see how to handle this case in the Dagger cookbook here: https://docs.dagger.io/cookbook/#continue-using-a-container-after-command-execution-fails.

    Essentially, you can start a shell, like this WithExec([]string{"sh", "-c", "npx playwright test || true"}). Then you can continue even on failure.

    There are ongoing plans to improve this, however, this isn't completed yet.

  2. GeitRavi commented on Sep 11, 2024

    @GeitRavi
    Author

    Thanks for response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions