Sails.js 将适配器更改为sails磁盘或sails内存时,sails无法提升
我想将sails与sails disk、migrate:drop一起使用,这样每当我运行testcase时,我就可以在local.js上拥有一个具有以下配置的新数据库。我对扬帆很满意。然而,一旦我更新了迁移:将或适配器拖放到sails磁盘或sails内存。我无法从引导中提升,在服务器下我甚至无法获得配置信息。船帆只需操纵即可升起。没有任何详细信息Sails.js 将适配器更改为sails磁盘或sails内存时,sails无法提升,sails.js,Sails.js,我想将sails与sails disk、migrate:drop一起使用,这样每当我运行testcase时,我就可以在local.js上拥有一个具有以下配置的新数据库。我对扬帆很满意。然而,一旦我更新了迁移:将或适配器拖放到sails磁盘或sails内存。我无法从引导中提升,在服务器下我甚至无法获得配置信息。船帆只需操纵即可升起。没有任何详细信息 #config.js module.exports = { models: { connection: 'testing',
#config.js
module.exports = {
models: {
connection: 'testing',
migrate: 'drop',
},
connections: {
testing: {
adapter: 'sails-disk',
host: '127.0.0.1',
user: 'test',
password: 'test',
database: 'db',
},
},
};
#bootstrap.test.js
const TestConfig = require('./config/local');
before((done) => {
// Increase the Mocha timeout so that Sails has enough time to lift.
Sails.lift({
connections: TestConfig.connections,
models: TestConfig.models,
}, function(err) {
if (err) { return done(err); }
return done(err, server);
});
});
#error message
after adding more debug information before return I can not get config information
1) "before all" hook
0 passing (3s)
1 failing
1) "before all" hook:
Uncaught TypeError: Cannot read property 'config' of undefined
at async.series (test/bootstrap.test.js:29:26)
at node_modules/async/dist/async.js:3888:9
at node_modules/async/dist/async.js:473:16
at replenish (node_modules/async/dist/async.js:1006:25)
at node_modules/async/dist/async.js:1016:9
at eachOfLimit (node_modules/async/dist/async.js:1041:24)
at node_modules/async/dist/async.js:1046:16
at _parallel (node_modules/async/dist/async.js:3879:5)
at Object.series (node_modules/async/dist/async.js:4735:5)
at Sails.lift (test/bootstrap.test.js:19:11)
由于您没有提供任何错误消息,我只能猜测您的配置是错误的。 您必须命名每个连接,并告诉您要使用哪个连接
module.exports = {
models: {
migrate: 'drop',
connection : 'testing',
},
connections: {
testing : {
adapter: 'sails-disk',
host: '127.0.0.1',
user: 'user',
password: 'password',
database: 'db',
}
},
},
非常感谢。这就是我实际做的..我在Description中更新了更多详细信息您可以查看(或粘贴在这里)该
test/bootstrap.test.js:29:26
-为什么'config'需要未定义的。谢谢。原来这可能是sails版本的问题。在我从sails v1.0.2降级到v.0.12.7之后,没有更改任何代码行。现在没事了你明白了吗?我还试图使数据库与每个测试套件之前刚打开时一样。是的。。我发现我的本地版本有问题。所以我清理一切,一步一步地调试,这样对我来说就很好了though@jacobcan118请你分享你的代码,我正在努力使我的测试工作在一个独立的数据库上,在每次测试之前都会被清理干净-