我在gitlab测试管道的所有测试中都有这个错误,但是本地所有测试都通过了。也许我错过了一些环境变量或者与Enzyme.configure有关({adapter:new Adapter()})?
npm任务:
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<link href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css" rel="stylesheet" />
<script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
<table width="100%" class="display" cellspacing="0" id="example">
<thead>
<tr>
<th>Distributor Name</th>
<th>Order Date</th>
<th>Product Name</th>
<th>NSP</th>
<th>Region</th>
<th>Current Sales</th>
<th>Closing Balance</th>
<th>Total Current Sales</th>
<th>Total Closing Balance</th>
<th>Total Closing Balance * 1.5</th>
<th>Current Sales * 1.5</th>
<th>(-)Closing Balance</th>
<th>Status</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Distributor Name</th>
<th>Order Date</th>
<th>Product Name</th>
<th>NSP</th>
<th>Region</th>
<th>Current Sales</th>
<th>Closing Balance</th>
<th>Total Current Sales</th>
<th>Total Closing Balance</th>
<th>Total Closing Balance * 1.5</th>
<th>Current Sales * 1.5</th>
<th>(-)Closing Balance</th>
<th>Status</th>
</tr>
</tfoot>
<tbody>
</tbody>
<!-- /.panel-heading -->
</table>
脚本/ test.js:
"test": "node scripts/test.js --env=jsdom"
Gitlab控制台错误:
'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)
Grid.spec.jsx:
$ 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)
答案 0 :(得分:0)
我终于发现NODE_ENV没有被设置为'测试'或'开发'(除了'生产'之外的东西)