i am using this filestack-js library and it works fine:
{areFilestackCredentialsAvailable ? (
<FileStackPicker
{...authRelatedProps}
pickerOptions={{
customText: {
[FILESTACK_PICKER_PLACEHOLDER_KEY]: t(
'COLLECTIONS_UPLOAD_COLLECTION_DOCUMENTS_MODAL_FILE_STACK_TEXT',
),
},
onFileSelected,
acceptFn: validateFile,
storeTo,
maxFiles: MAX_NUMBER_OF_ALLOWED_FILES,
}}
onUploadDone={onUploadDone}
onRemoveFile={onRemoveFile}
fileBlocks={fileBlocks}
/>
) : (
<S.Loader />
)}
but when im trying to run it in vitest:
it('should render FileUploadModal with correct texts', async () => {
render(
<Wrapper>
<FileUploadModal {...mockProps} />
</Wrapper>,
)
expect(screen.getByText('Upload collection documents')).toBeInTheDocument()
expect(
screen.getByText(
'Uploaded documents to be used for collection insights during the order',
),
).toBeInTheDocument()
expect(
screen.getByText('PNG, PDF, TXT, DOC, DOCX, PPT, PPTX, XLS, XLSX (Max file size 20MB)'),
).toBeInTheDocument()
await delay(5010)
debug()
await waitFor(
() => {
expect(screen.getByText('Drag & Drop or Click to upload file')).toBeInTheDocument()
},
{ timeout: 10000 },
)
const finishModalButton = screen.getByText('Finish')
expect(finishModalButton).toBeInTheDocument()
})
for some reason it throws me this error:
TypeError: Picker is not a constructor
❯ PickerLoader.<anonymous> node_modules/filestack-js/build/src/lib/picker.ts:833:12
❯ step node_modules/tslib/tslib.js:196:27
❯ Object.next node_modules/tslib/tslib.js:177:57
❯ fulfilled node_modules/tslib/tslib.js:167:62
and does not render the file upload component. i have tried to use diffrent versions, but for some reason the test thinks im using picker function, which im not using it at all. to only place im using filestack-js in this component its in the 'useFileStack' hook:
filestackClientRef.current = filestack.init(apiKey, {
security,
})
thanks for helping!