0
gitlabテストパイプラインのすべてのテストでこのエラーが発生しましたが、すべてのテストにはローカルに渡されます。たぶん私はいくつかの環境変数がないか、Enzyme.configure({adapter:new Adapter()})と関係があるでしょうか?反応テストレンダラーの浅いレンダラーはプロダクションモードで利用できません
NPMタスク:
"test": "node scripts/test.js --env=jsdom"
スクリプト/ test.js:
'use strict'
const jest = require('jest')
// Makes the script crash on unhandled rejections instead of silently
// ignoring them. In the future, promise rejections that are not handled will
// terminate the Node.js process with a non-zero exit code.
process.on('unhandledRejection', (err) => {
throw err
})
const argv = process.argv.slice(2)
// Watch unless on CI or in coverage mode
if (!process.env.CI && argv.indexOf('--coverage') < 0) {
argv.push('--watch')
}
jest.run(argv)
Gitlabコンソールエラー:
$ node scripts/test.js --env=jsdom
FAIL src/components/ui/Grid/__tests__/Grid.spec.jsx
● Test suite failed to run
shallow renderer is not available in production mode.
at Error (native)
at Object.<anonymous> (node_modules/react-test-renderer/shallow.js:4:9)
at Object.<anonymous> (node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:21:16)
at Object.<anonymous> (node_modules/enzyme-adapter-react-16/build/index.js:2:18)
at Object.<anonymous> (src/components/ui/Grid/__tests__/Grid.spec.jsx:3:27)
Grid.spec.jsx:
import React from 'react'
import Enzyme, { shallow } from 'enzyme'
import Adapter from 'enzyme-adapter-react-16'
import Grid from '../index'
const { Row, Column } = Grid
Enzyme.configure({ adapter: new Adapter() })
describe('Grid',() => {
it('should have a Row and a Column',() => {
expect(Grid.Row).toBeDefined()
expect(Grid.Column).toBeDefined()
})
})