简体   繁体   English

React / Babel:组件不只在CircleCI上渲染

[英]React/Babel: Components not rendering only on CircleCI

I've recently added ReactJS with React-Redux and Babelify (for ES6) to a Rails application. 我最近将带有React-Redux和Babelify(用于ES6)的ReactJS添加到了Rails应用程序中。 The cucumber tests are passing locally, but they are not passing on CircleCI. 黄瓜测试在本地通过,但没有通过CircleCI。 Here is what I know so far: 到目前为止,这是我所知道的:

  • When I check screenshots in the artifacts, it appears the React components are not rendering, even while waiting up to 4 seconds for them to appear. 当我检查工件中的屏幕截图时,即使等待最多4秒钟才能显示它们,React组件也似乎没有呈现。
  • There are no errors in the CircleCI build CircleCI版本中没有错误
  • I've tried rebuilding on CircleCI without the cache. 我试过在没有缓存的CircleCI上重建。
  • Basic javascript-reliant tests are passing. 基本的javascript相关测试都通过了。
  • Basic tests that rely on babel and importing a library (lodash) are passing 依赖babel和导入库(lodash)的基本测试通过了

How can I get my cucumber tests of React components to pass on CircleCI? 我如何才能使我的React组件的黄瓜测试通过CircleCI?

# no circle.yml

# gemfile
gem 'capybara-webkit'
gem "chromedriver-helper"
gem 'capybara-screenshot'
gem 'selenium-webdriver'

# package.json
"dependencies": {
  "browserify": "~> 10.2.4",
  "browserify-incremental": "^3.0.1",
  "lodash": "^3.10.1",
  "react": "~>0.13.3",
  "react-redux": "~>3.1.0",
  "redux-thunk": "~>1.0.0",
  "babelify": "~>6.3.0"
}

# support/env.rb
Capybara.register_driver :chrome do |app|
  Capybara::Selenium::Driver.new(app, browser: :chrome)
end
Capybara.javascript_driver = :chrome

After SSHing into the CircleCI tests, my colleague saw that Object.assign was undefined. 通过SSH进入CircleCI测试后,我的同事发现Object.assign未定义。 Apparently CircleCI is using an older version of Chrome than we have been for our tests, and Babel does not automatically polyfill that ES6 method (see comments for more info). 显然,CircleCI使用的Chrome版本比我们测试时使用的版本要旧,并且Babel不会自动填充该ES6方法(请参阅注释以获取更多信息)。

He replaced Object.assign() with lodash's _.extend() and tests are green everywhere. 他用lodash的_.extend()代替了Object.assign() ,并且测试处处都是绿色。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM