-
Notifications
You must be signed in to change notification settings - Fork 5
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
Usage in factories? #14
Comments
So I've done some digging and found that if in my model decorator I have import { ResponsiveAttachment } from '@ioc:Adonis/Addons/ResponsiveAttachment';
import Factory from '@ioc:Adonis/Lucid/Factory';
import ServiceProviderProfile from 'App/Models/ServiceProviderProfile';
import { readFile } from 'node:fs/promises';
import { join } from 'node:path';
export default Factory.define(ServiceProviderProfile, async ({ faker }) => {
const avatarImage = await ResponsiveAttachment.fromBuffer(
await readFile(join(__dirname, '../../tests/resources/default-avatar.png'))
);
return {
name: faker.name.fullName(),
avatar: avatarImage,
type: faker.helpers.arrayElement(['mental', 'physical']) as 'mental' | 'physical',
about: faker.random.words(30),
specialties: faker.random.words(5).split(' ').join(', ')
};
}).build();
|
Please confirm if this still persist in v1.5.0. Thank you. |
Seems to be working for me now when If you don't mind me asking, how was it fixed? |
I can't say what fixed it as I haven't used the add-on in a factory context yet 😄. But I definitely know that a lot of improvements where made from v1.5.0. Glad that it is working for you as expected. |
I may have closed too early. Seems fine when running in a test context, but in a seeder context it fails.
|
This is a short conversation about it on discord So I think something in adonis itself would need to change to make it work properly in every context. |
* feat: upgrade to new japa version * style(test): run prettier
I have a factory like so
The images are processed and saved to disk.
avatarImage
is the correct object before the return. Is there something else I need to do to make this work in a factory?The text was updated successfully, but these errors were encountered: