Gitlab 管道尝试运行 Microsoft Playwright 测试时出现“shell not found”错误

问题描述 投票:0回答:2

我在 Gitlab 上运行 Microsoft Playwright 时遇到问题。 当我开始测试时,在拉取图像后出现shell not found错误。

YML 文件

stages:
   - test

tests:
  rules:
      - when: manual
  stage: test
  image: mcr.microsoft.com/playwright:v1.41.1-jammy
  script:
    - npm ci
    - npx playwright test
  artifacts:
    paths:  
      - playwright-report
      - test-results
      - results.xml/
    when: always
    expire_in: 120 days  
    reports:
        junit: results.xml

下面突出显示的错误

有人可以让我知道我做错了什么吗?

谢谢

docker gitlab automated-tests playwright playwright-typescript
2个回答
0
投票

您的问题可能有两种解决方法。

  1. 通过添加和更改以下行来编辑您的
    config.toml
    文件:

config.toml

...
executor = "docker"
shell = "bash" ## <- add this line
[runners.cache] 
    MaxUploadedArchiveSize = 0 
[runners.docker] 
    tls_verify = false 
    image = "ruby:2.7" 
    privileged = true ## <- and this to true
    disable_entrypoint_overwrite = false 
    oom_kill_disable = false 
    disable_cache = false 
    volumes = ["/cache"] 
    shm_size = 0
  1. 如果这不起作用,请通过添加
    /bin/sh
    /bin/bash
    入口点将管道中的图像关键字更改为此:
stages:
   - test

tests:
  ...
  stage: test
  image: 
    name: mcr.microsoft.com/playwright:v1.41.1-jammy
    entrypoint: [ '/bin/sh', '-c' ] # or entrypoint: [ '/bin/bash', '-c' ]
  script:
    - npm ci
    - npx playwright test
  ...

0
投票

我通过使用 tsconfig 路径映射弄清楚了。 在我的根目录中添加了 tsconfig.json 文件,然后使用下面的映射

{
    "compilerOptions": {
      "baseUrl": "./",  
      "paths": {
        "@pages/*": ["pages/*"]  
      }
    }
  }

感谢@EnergY您对原始问题的建议 我希望这可以帮助别人

© www.soinside.com 2019 - 2024. All rights reserved.