开玩笑给我的测试套件结果是“ TypeError:构造函数集需要'new'”
.babelrc配置为:
select prod_a as "Prod",
prod as "Range of Amounts",
value as "Mean Price"
from
(
with tablea(prod,amt,price) as
(
select 'X',100,1 from dual union all
select 'X',180,2 from dual union all
select 'X',250,3 from dual union all
select 'Y',90, 2 from dual union all
select 'Y',170,3 from dual union all
select 'Y',280,3 from dual
)
select prod as prod_a,
avg(case when amt between 0 and 200 then price end) as avg_0_200,
avg(case when amt between 150 and 300 then price end) as avg_150_300
from tablea a
group by prod
) b
unpivot(value for prod in(avg_0_200,avg_150_300))
order by prod_a;
Prod Range of Amounts Mean Price
---- ---------------- ----------
X AVG_0_200 1.5
X AVG_150_300 2.5
Y AVG_0_200 2.5
Y AVG_150_300 3
测试套件:
{
"presets": [["env", { "modules": false }]],
"env": {
"test": {
"presets": [["env"]]
}
}
}
预计该测试将通过。而是显示错误:
test('Constructor Set requires "new"', () => {
class A extends Set {
constructor(...arg) {
super(...arg);
this.add(10);
}
}
const a = new A([1, 2]);
expect([...a][2]).toEqual(10);
});
答案 0 :(得分:1)
要解决此问题,必须为preset-env
插件设置目标。对于jest
,它是node
。 (可以将其放在"test"
的{{1}}部分中)
.bybelrc