Open adamski opened 9 years ago
@adamski Scenario requires all your models to be loaded before it can populate them. If the example you posted is the full contents of the gulp.task()
definition then you need to include something along the lines of require('./models/tropics')
beforehand so that Mongoose is aware of your model definition.
Better yet saving the below as ./models/index.js
allows you to load all of your models at once using require('./models')
:
var requireDir = require('require-dir');
requireDir('./');
Hope this helps.
Sorry, It was not the full gulp task I posted.
At the top of my gulp task I have:
var modelsFolderPath = __dirname + '/models/';
//...
fs.readdirSync(modelsFolderPath).forEach(function (modelFile) {
require(modelsFolderPath+modelFile);
});
If you've included the model files it should be fine then.
My guess would be that the naming convention used in your model file doesn't match the one you are giving to Scenario.
It looks like you're trying to populate the Topic
collection in your Scenario schema. Does this match the name you are passing to mongoose.model(NAME, SCHEMA)
?
Other than that, all I can think off the top of my head is that Mongoo is perhaps rewriting the model names. I know for example that all collections are usually automatically lower cased (i.e. try topics
instead of Topics
).
I've been trying this out for our project but run into an issue.
I have a JSON file
tests/scenarios/topics.json
:In my
gulpfile.js
task I haveBut the topics collection is not created. However, a similarly formatted JSON file for users does go in.
I tried with a root value of "topics" but get the error
What do the scenario
.json
files look like?