Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server.createList() and server.create() creates duplicate values with dynamic factory definition #57

Open
tomcorey26 opened this issue Dec 21, 2020 · 0 comments

Comments

@tomcorey26
Copy link

tomcorey26 commented Dec 21, 2020

In my server I defined a factory

    factories: {
      story: Factory.extend<UserStory>({
        get userStory() {
          return faker.name.jobDescriptor();
        },
        get name() {
          return faker.name.title();
        },
        get link() {
          return faker.internet.url();
        },
        get status(): StoryStatus {
          const num = getRandomInt(1, 4) as 1 | 2 | 3; //ranom
          if (num === 1) {
            return "Construction";
          } else if (num === 2) {
            return "Design";
          } else {
            return "Release";
          }
        },
        get proxy() {
          return faker.name.firstName();
        },
      }),
    },

But when I call createList in my seeds function I am just getting a duplicate object for each of the 20 values

  seeds(server) {
      server.createList("story", 20);
    }

Screen Shot 2020-12-21 at 3 28 54 PM

I even tried just doing

  seeds(server) {
      server.create("story");
      server.create("story");
      server.create("story");
    }

and each server.create() give me the same value.

I want it so I am give a unique object with different properties for each value, but it doesnt seem to be working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant