我正在尝试测试下面这段代码。
const Datastore = require('@google-cloud/datastore');
// Creates a client
const datastore = new Datastore({
projectId: serviceConfig.projectId
});我的测试文件包含
function MockDatastore (config) {
this.projectId = config.projectId;
}
var datastoreStub = {Datastore:MockDatastore}
return proxyquire('../../../app/persistence', {
'@google-cloud/datastore': datastoreStub
});根据%1,这应该是允许的。
发布于 2019-01-31 18:55:32
从API change 2.x开始,您应该使用以下代码:
const { Datastore } = require("@google-cloud/datastore");这对我来说很有效。
https://stackoverflow.com/questions/52757791
复制相似问题