Git Product home page Git Product logo

Comments (8)

jcteague avatar jcteague commented on May 31, 2024

That's an interesting idea. One of the key features is the ability to customize the object the fixture returns to meet specific test criteria. How would you propose to do that with an import statement?

A PR would be welcome!

from autofixturejs.

entropitor avatar entropitor commented on May 31, 2024

You mean that you can override properties? I think that should still be possible.

At the moment I started using rosie, they allow both to import by ES6 modules and to use the singleton pattern that you are using.
See https://github.com/rosiejs/rosie#usage-in-es6

from autofixturejs.

jcteague avatar jcteague commented on May 31, 2024

Interesting. Rosie looks like it follows a lot of the same patterns autofixture does.

I do see some advantages to do it this way.

It's possible to simulate this now if you export the build function in the Rosie example

// user-fixture.js
import {AutoFixtures as Factory} from 'autofixture'
Factory.define('user', ['first_name','last_name','email']);
export default function(overrides) { return Factory.create('user', overrides) }
// test.js
import { UserFixture } from 'user-fixture';
const user = UserFixture({email: 'test3mail'});

It would not take much to refactor autofixture to make this easier.

from autofixturejs.

entropitor avatar entropitor commented on May 31, 2024

Yes although, multiple models can't define the user factory because of the singleton global namespace

from autofixturejs.

jcteague avatar jcteague commented on May 31, 2024

from autofixturejs.

entropitor avatar entropitor commented on May 31, 2024

They might be completely different objects that happen to have the same name. If you're reusing the module system, I don't think you need to complicate that with a global namespace

from autofixturejs.

jcteague avatar jcteague commented on May 31, 2024

from autofixturejs.

jcteague avatar jcteague commented on May 31, 2024

I just added this feature to v1.1. I haven't documented it yet, but there's a couple of tests to show the return object from a create call that can be exported

from autofixturejs.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.