【发布时间】:2018-09-25 02:46:43
【问题描述】:
我想将sails 与sails-disk 一起使用,迁移:drop 以便每当我运行测试用例时,我都可以在local.js 上拥有一个具有以下配置的新数据库。我对风帆升降机很好。但是,一旦我更新了 migrate: drop 或 adapter 到sails-disk 或sails-memory。我无法从引导程序和服务器下航行,我什至无法获取配置信息。帆升降只是搬运。没有任何详细信息。
#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)
【问题讨论】:
-
好吧,您可以查看(或粘贴到此处)
test/bootstrap.test.js:29:26上的内容 - 为什么“配置”要求未定义。 -
谢谢。原来这可能是帆版问题。在我从sails v1.0.2 降级到v.0.12.7 之后,没有更改任何代码行。现在好了
-
你弄明白了吗?我还试图让数据库与每个测试套件之前刚刚解除时的数据库相同。
-
是的。我发现我的本地版本有问题。所以我清理了所有内容并逐步调试,但对我来说没问题
-
@jacobcan118 请你分享你的代码,我正在努力让我的测试在一个单独的数据库上工作,每次测试前都会清理它 - stackoverflow.com/q/53638665/1828637
标签: sails.js