A test util that helps to fill files in your file input element
fillInFile('#input-element', { url: 'base64content', name: 'example.jpg' })
npm install fill-in-file
Please check this article for implementation details.
fillInFile('#input-element')
It automatically adds the mock js-base64 image and triggers the onchange event.
fillInFile('#input-element', 'base64content')
or
fillInFile('#input-element', 'https://some-public-file-url.jpg');
fillInFile('#input-element', { url: 'base64content', name: 'logo.jpg' });
or
fillInFile('#input-element', { url: 'https://some-public-file-url.jpg', name: 'profile.jpg' });
It adds the given file to the file input and triggers the onchange event.
let files = [
{ url: 'base64content', name: 'logo.jpg' },
{ url: 'https://some-public-file-url.jpg', name: 'profile.jpg' }
];
fillInFile('#input-element', files);
Method: fillInFile
params:
name | type | required | description |
---|---|---|---|
domSelector | string | yes | dom query selector string for the input file element |
files | undefined - string - file - [file] | optional | file contents to be added to the file element |
options | object | optional | supports options like documentContext that lets you pass a custom document context, by default util uses global document |
https://github.com/prakashchokalingam/ember-fill-in-file
Qunit: https://prakashchokalingam.github.io/fill-in-file/examples/qunit.html
Mocha: https://prakashchokalingam.github.io/fill-in-file/examples/mocha.html