https://github.com/john-doherty/jsdom-add-files
An easy way to add files to HTML file inputs in jsdom
https://github.com/john-doherty/jsdom-add-files
Last synced: about 2 months ago
JSON representation
An easy way to add files to HTML file inputs in jsdom
- Host: GitHub
- URL: https://github.com/john-doherty/jsdom-add-files
- Owner: john-doherty
- License: mit
- Created: 2021-10-16T13:09:02.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-10-16T13:36:04.000Z (over 4 years ago)
- Last Synced: 2025-12-26T12:51:57.901Z (5 months ago)
- Language: JavaScript
- Size: 13.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jsdom-add-files
Adds local files to a HTML file input in jsdom and fires the `change` event. Inspired by jsdom ticket [#1272](https://github.com/jsdom/jsdom/issues/1272)
## Install
```bash
npm install --save jsdom-add-files
```
## Usage
```js
var path = require('path');
var jsdomAddFiles = require('jsdom-add-files');
// get file input
var fileInput = document.querySelector('input[type="file"]');
// add files (automatically fires onchange event)
jsdomAddFiles(fileInput, [
path.join(__dirname, 'file1.jpg'),
path.join(__dirname, 'file2.jpg'),
path.join(__dirname, 'file3.png')
]);
```
## License
Licensed under [MIT License](LICENSE) © [John Doherty](https://twitter.com/mrjohndoherty)