Comments (8)
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.
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.
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.
Yes although, multiple models can't define the user
factory because of the singleton global namespace
from autofixturejs.
from autofixturejs.
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.
from autofixturejs.
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)
- Potential name confusion HOT 6
- any support on foreignkey auto-generate? HOT 2
- TypeScript types? HOT 1
- Version 2.0 rewrite HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from autofixturejs.