v. 5.0.4
node: 10.3.0
npm: 6.4.0
A sample test case that make use of the "create" method on the defined "User" model.
test("Cannot have two same username", async ({ client, assert }) => {
const user = await Factory.model("App/Models/User").create();
const response = await client
.post("/signup")
.send({
username: user.username,
email: "[email protected]",
password: "aPassword",
password_confirmation: "aPassword"
})
.end();
response.assertStatus(400);
response.assertJSONSubset({
status: "fail",
data: {
errors: [
{
message: "unique validation failed on username",
field: "username",
validation: "unique"
}
]
}
});
});
Launching adonis test gives back Cannot read property 'name' of undefined. I saw you use a name property inside the factory index file, but I didn't have time to check the code better. Am I doing something wrong?
I'm sorry, I wasn't defining any blueprint in the factory.js file!
Most helpful comment
I'm sorry, I wasn't defining any blueprint in the factory.js file!