Core: TypeError: faker.foo is not a function

Created on 4 Mar 2019  路  3Comments  路  Source: adonisjs/core

Package version

AdonisJs version 4.1.0

Node.js and npm version

npm version: 6.5.0
Node.js version: 11.8.0
mysql version: 14.14

Sample Code

Schema file:

up () {                                                                                                                                        
    this.create('examples', (table) => {                                                                                                         
      table.increments()                                                                                                                         
      table.string('foo', 30).notNullable()                                                                                                      
      table.string('bar', 30).notNullable()                                                                                                      
    })                                                                                                                                           
  }   

factory.js:

Factory.blueprint('App/Models/Example', (faker) => {                                                                                             
  return {                                                                                                                                       
    foo: faker.foo(),                                                                                                                            
    bar: faker.bar()                                                                                                                             
  }                                                                                                                                              
})    

BONUS (a sample repo to reproduce the issue)

Clone my repository: https://github.com/begueradj/bugs/tree/master/seed-bug

Most helpful comment

Hey @begueradj ! 馃憢

I don't know what you are trying to do.

The faker variable is a ChanceJS instance.
There's no foo nor bar method on it.

All 3 comments

Hey @begueradj ! 馃憢

I don't know what you are trying to do.

The faker variable is a ChanceJS instance.
There's no foo nor bar method on it.

I have been navigating the source code of AdonisJS to see where such things come from because I felt something was wrong with faker.something(). That is totally new for me. I bookmark it. Thank you so much @RomainLanz This framework is really amazing and easy to learn. Even testing is so easy with it.

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  3Comments

umaams picture umaams  路  3Comments

themodernpk picture themodernpk  路  3Comments

PC-HUB picture PC-HUB  路  4Comments

devcaststudio picture devcaststudio  路  3Comments