gpt4 book ai didi

javascript - 为什么我的 Jasmine 规范是 'No specs found'

转载 作者:数据小太阳 更新时间:2023-10-29 04:47:24 25 4
gpt4 key购买 nike

我的 Javascript 函数是

function Investment (params) {
var params = params || {};
this.stock = params.stock;
this.shares = params.shares
this.cost = params.cost
};

我的规范是

describe("Investment", function() {

beforeEach(function() {
this.stock = new Stock();
this.investment = new Investment({
stock: this.stock,
shares: 100
cost: 2000
});
});

it("should be a stock", function() {
expect(this.investment.stock).toBe(this.stock);
});

it("should have the invested shares quantity", function() {
expect(this.investment.shares).toEqual(100);
});

it("should have a cost", function() {
expect(this.investment.cost).toEqual(2000);
});
});

最佳答案

规范在其中一个参数后缺少一个逗号,因此应该是:

beforeEach(function() {
this.stock = new Stock();
this.investment = new Investment({
stock: this.stock,
shares: 100, <-- needs a comma here
cost: 2000
});
});

关于javascript - 为什么我的 Jasmine 规范是 'No specs found',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39226398/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com