最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

TypeError: Picker is not a constructor in filestack-js and filestack-react in vitest - Stack Overflow

programmeradmin2浏览0评论

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!

发布评论

评论列表(0)

  1. 暂无评论