jest-xlsx-loader

1.0.0 • Public • Published

Jest XLSX Loader

Imports and parses xlsx files for usage with the xlsx npm module.

For webpack usage, see the webpack xlsx npm module.

Install

npm install --save-dev jest-xlsx-loader

Usage

Add this to your package.json. Note: babel-jest is only required if you want to continue transpiling js with babel.

"jest"{
  "transform": {
    "\\.jsx?$": "babel-jest",
    "\\.xlsx$": "jest-xlsx-loader"
  }
}

You can then directly import and use xlsx to manipulate your excel spreadsheet (if you need more complicated functionality).

import spreadsheet from './spreadsheet.xlsx'
import xlsx from 'xlsx'
 
test('that spreadsheet correctly imported', () => {
  expect(spreadsheet.SheetNames).toEqual(jasmine.arrayContaining([jasmine.any(String)]))
 
  const csvString = xlsx.utils.sheet_to_csv(spreadsheet.Sheets['Sheet1'])
})

License

MIT © Severin Ibarluzea

Readme

Keywords

none

Package Sidebar

Install

npm i jest-xlsx-loader

Weekly Downloads

114

Version

1.0.0

License

MIT

Last publish

Collaborators

  • seveibar