Skip to main content
Version: 1x

@qavajs/steps-files

Step library to work with file system

Installation

npm install @qavajs/steps-files@1

Configuration

module.exports = {
default: {
require: [
'node_modules/@qavajs/steps-files/index.js'
],
// add fileTimeout property in case you need to customize built-in interval and timeout
fileTimeout: {
interval: 1000,
timeout: 1000
}
}
}

Parameter types

fileValidation

validation of values (can be negated with not)

  • to be equal
  • to be strictly equal
  • to be deeply equal
  • to have member
  • to be match
  • to contain
  • to be above
  • to be below
  • to be greater than
  • to be less than
  • to have type

Wait Steps


I wait until file matching {string} regexp appears in {string}

Wait until file matching regexp appear in directory

paramtypedescriptionexample
filestringfile name regex to waitf.+.txt
dirstringdirectory path to wait./yourFolder
When I wait until file matching 'f.+\.txt' regexp appears in './test-e2e/folder'
When I wait until file matching '$fileRegexp' regexp appears in '$folder'

I wait until {string} file appears

Wait until file appear

paramtypedescriptionexample
filestringfile path to wait./yourFolder/file.txt
When I wait until './test-e2e/folder/file.txt' file appears
When I wait until '$filePath' file appears

Validation Steps


I expect {string} text file content {fileValidation} {string}

Verify that text file content satisfy validation

paramtypedescriptionexample
filestringfile path./yourFolder/file.txt
validationTypestringfile pathto be equal, to contain
expectedValuestringexpected valuetext, $value
When I expect './folder/file.txt' text file content to be equal 'file content'
When I expect '$filePath' text file content to contain '$content'

Memory Steps


I save {string} file content as {string}

Save file content to memory as buffer

paramtypedescriptionexample
filestringfile path./yourFolder/file.jpeg
memoryKeystringmemory keyfileContent, value
When I save './folder/file.txt' file content as 'fileContent'
When I save '$filePath' file content as 'fileContent'

I save {string} text file content as {string}

Save file content to memory as text (utf-8)

paramtypedescriptionexample
filestringfile path./yourFolder/file.txt
memoryKeystringmemory keytextContent, value
When I save './folder/file.txt' text file content as 'fileContent'
When I save '$filePath' text file as 'fileContent'

I save {string} Excel file content as {string}

Save file content to memory as Excel object (https://www.npmjs.com/package/xlsx)

paramtypedescriptionexample
filestringfile path./yourFolder/file.xlsx
memoryKeystringmemory keyexcelContent, value
When I save './folder/file.txt' Excel file content as 'fileContent'
When I save '$filePath' Excel file as 'fileContent'
# if you use @qavajs/steps-memory package
Then I expect '$excelFile.Sheets.SheetName.A1.v' to be equal 'expectedValueOfCell'

I save {string} pdf file content as {string}

Save file content to memory as pdf object with following properties:

propertytypedescription
textMultiLinestringtext of pdf in multiline format
textSingleLinestringtext of pdf in single-line format
metadataObjectpdf metadata
paramtypedescriptionexample
filestringfile path./yourFolder/file.txt
memoryKeystringmemory keytextContent, value
When I save './folder/file.pdf' pdf file content as 'pdfContent'
When I save '$filePath' pdf file content as 'pdfContent'
# if you use @qavajs/steps-memory package
Then I expect '$pdfContent.textMultiLine' to be equal 'expectedPdfContent'
Then I expect '$pdfContent.textSingleLine' to be equal 'expectedPdfContent'

I save {string} Word file content as {string}

Save file content to memory as word object with following properties:

propertytypedescription
textMultiLinestringtext of word document in multiline format
textSingleLinestringtext of word document in single-line format
paramtypedescriptionexample
filestringfile path or buffer./yourFolder/file.docx
memoryKeystringmemory keywordContent, value
When I save './folder/file.docx' Word file content as 'wordContent'
When I save '$filePath' Word file content as 'wordContent'
When I save '$fileBuffer' Word file content as 'wordContent'
# if you use @qavajs/steps-memory package
Then I expect '$wordContent.textMultiLine' to be equal 'expectedPdfContent'
Then I expect '$wordContent.textSingleLine' to be equal 'expectedPdfContent'

I save {string} csv file content as {string}

Save file content to memory as csv object. First row will is considered as header.

paramtypedescriptionexample
filestringfile path or buffer./yourFolder/file.csv
memoryKeystringmemory keycsvContent, value
When I save './folder/file.csv' csv file content as 'csvContent'
When I save '$filePath' csv file as 'csvContent'
# if you use @qavajs/steps-memory package
Then I expect '$csvContent[0].columnName' to be equal 'expectedValue'