I am here. MODEL TESTING PATTERNS Methods I Step 6.
I have the exact same code as the solution. When I go into the solution help, it doesn’t highlight any code as different. Yet, when I run the test, it is apparently not giving the exact error code it is looking for. So, the step fails and I can’t move forward. If I tell it to use the solution code, it will fill in the entire solution and will keep me from being able to do steps 7 and 8 myself.
I have no choice, though, so I will have it swap the ‘solution code’ in and spoil my ability to write the following steps myself.
Here is the code I wrote:
dinosaur.js:
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const validator = function(value) {
return value <= 10;
};
const DinosaurSchema = new Schema(
{
name: {type: String, required: true},
count: {
type: Number,
max: [10, 'Cannot hold more than 10 dinosaurs.']
},
risk: {type: String}
}
);
// Define .findByName here
DinosaurSchema.statics.findByName = function(name, callback) {
return this.findOne({ name: name }, callback);
};
module.exports = mongoose.model('Dinosaur', DinosaurSchema);
Here is the ‘solution code’:
dinosaur.js
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const validator = function(value) {
return value <= 10;
};
const DinosaurSchema = new Schema(
{
name: {type: String, required: true},
count: {
type: Number,
max: [10, 'Cannot hold more than 10 dinosaurs.']
},
risk: {type: String}
}
);
// Define .findByName here
DinosaurSchema.statics.findByName = function(name, callback) {
return this.findOne({ name: name }, callback);
};
module.exports = mongoose.model('Dinosaur', DinosaurSchema);
This is what my screen looks like when it errors:
This is what the terminal logs after running npm test:
$ npm test
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
path.js:1142
cwd = process.cwd();
^
Error: ENOENT: no such file or directory, uv_cwd
at Object.resolve (path.js:1142:25)
at Function.Module._resolveLookupPaths (module.js:391:17)
at Function.Module._resolveFilename (module.js:461:31)
at Function.Module._load (module.js:418:25)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at /usr/lib/node_modules/npm/bin/npm-cli.js:19:21
at Object.<anonymous> (/usr/lib/node_modules/npm/bin/npm-cli.js:79:3)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
The dinosaur-test.js file did not change since the last time it passed, and the solution comparison also highlights no differing code.
Just reporting it so that you are aware of this glitch.