【问题标题】:BitBucket Jest tests get stuckBitBucket Jest 测试卡住了
【发布时间】:2022-10-19 17:10:07
【问题描述】:

当管道进入测试时(开玩笑)。它只是呆在那里,微调器继续旋转,没有任何反应,没有错误消息。测试在本地运行,没有错误。 谷歌搜索后,我注意到由于 cpu/内存问题,人们建议开玩笑地使用--maxWorkers=20%。但它没有帮助。

像这样触发 webpack 中的测试:

"test": "jest --coverage --watchAll --maxWorkers=20% --maxConcurrent=2 --verbose --config=configs/jest.json",

我在 bitbucket 中有这个管道设置:

image: node:16

pipelines:
  default:
      - step:
          name: Build
          caches:
            - node
          script:
            - npm install
            - npm run build
            - npm run test
          artifacts:
            - dist/**
      - step:
          name: Deploy to S3
          deployment: production
          trigger: manual
          script:
            - pipe: atlassian/aws-s3-deploy:1.1.0
              variables:
                AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
                AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
                AWS_DEFAULT_REGION: 'eu-west-1'
                S3_BUCKET: 'myname'
                LOCAL_PATH: 'dist'
      - step:
          name: Invalidate CloudFront cache
          trigger: automatic
          script:
            - pipe: atlassian/aws-cloudfront-invalidate:0.6.0
              variables:
                AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
                AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
                DISTRIBUTION_ID: 'E3HTTJFUB2KUCW'

如果重要的话,这是开玩笑的配置文件。

{
  "rootDir": "..",
  "testEnvironment": "jsdom",
  "coverageDirectory": "<rootDir>/tests/__coverage__/",
  "setupFiles": [
    "<rootDir>/tests/__mocks__/shim.js"
  ],
  "roots": [
    "<rootDir>/src/",
    "<rootDir>/tests/"
  ],
  "moduleNameMapper": {
    "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/tests/__mocks__/fileMock.js",
    "\\.(css|scss|less)$": "<rootDir>/tests/__mocks__/styleMock.js"
  },
  "moduleFileExtensions": [
    "ts",
    "tsx",
    "js",
    "jsx"
  ],
  "transformIgnorePatterns": [
    "/node_modules/"
  ],
  "testRegex": "/tests/.*\\.(ts|tsx)$",
  "moduleDirectories": [
    "node_modules"
  ],
  "globals": {
    "DEVELOPMENT": false,
  }
}

【问题讨论】:

  • 你让它运行了多久?
  • 我让它停留了20分钟,仍然卡住了。但是我将 webpack 中的脚本更改为"test": "jest --maxWorkers=20% --maxConcurrent=2 --verbose --config=configs/jest.json,现在可以正常工作了。不确定这是否是正确的方法。

标签: jestjs bitbucket bitbucket-pipelines


【解决方案1】:

--watchAll=false 应该让你退出菜单。

【讨论】:

    猜你喜欢
    • 2012-10-14
    • 1970-01-01
    • 2019-04-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-04
    • 2012-06-23
    • 2021-10-08
    相关资源
    最近更新 更多