dataverse-client-javascript icon indicating copy to clipboard operation
dataverse-client-javascript copied to clipboard

test/integration/files/DirectUploadClient.test.ts fails in local dev environment

Open ekraffmiller opened this issue 1 year ago • 2 comments

When running the test script locally, DirectUploadClient.test.ts fails, but it succeeds in the Github action. If possible, we need to update the docker configuration in the test to handle this use case.

To recreate, run:

npm test

Test output:

`hmdcloaner@HMDC-HMDCs-MacBook-Pro dataverse-client-javascript % npm test

[email protected] test jest -c jest.config.ts

Determining test suites to run...Cleaning up old container volumes... Running test containers... Test containers up and running Obtaining test API key... API key obtained PASS test/unit/datasets/UpdateDataset.test.ts PASS test/unit/collections/CollectionsRepository.test.ts PASS test/unit/datasets/CreateDataset.test.ts PASS test/unit/datasets/DatasetResourceValidator.test.ts PASS test/unit/datasets/DatasetsRepository.test.ts PASS test/unit/info/DataverseInfoRepository.test.ts PASS test/unit/files/FilesRepository.test.ts PASS test/unit/metadataBlocks/MetadataBlocksRepository.test.ts PASS test/unit/users/UsersRepository.test.ts PASS test/integration/metadataBlocks/MetadataBlocksRepository.test.ts PASS test/functional/metadataBlocks/GetCollectionMetadataBlocks.test.ts PASS test/integration/info/DataverseInfoRepository.test.ts PASS test/unit/files/GetFileAndDataset.test.ts PASS test/unit/files/GetFile.test.ts PASS test/unit/datasets/GetPrivateUrlDatasetCitation.test.ts PASS test/unit/datasets/PublishDataset.test.ts PASS test/integration/users/UsersRepository.test.ts PASS test/integration/auth/AuthRepository.test.ts PASS test/unit/files/GetDatasetFilesTotalDownloadSize.test.ts PASS test/unit/collections/GetCollection.test.ts PASS test/unit/datasets/GetPrivateUrlDataset.test.ts PASS test/unit/datasets/GetDatasetUserPermissions.test.ts PASS test/unit/auth/AuthRepository.test.ts PASS test/functional/collections/CreateCollection.test.ts PASS test/unit/files/GetDatasetFileCounts.test.ts PASS test/unit/files/AddUploadedFileToDataset.test.ts PASS test/unit/collections/CreateCollection.test.ts PASS test/unit/info/GetDataverseVersion.test.ts PASS test/unit/datasets/GetDataset.test.ts PASS test/unit/metadataBlocks/GetCollectionMetadataBlocks.test.ts PASS test/unit/datasets/datasetTransformers.test.ts PASS test/functional/datasets/UpdateDataset.test.ts PASS test/unit/metadataBlocks/GetMetadataBlockByName.test.ts PASS test/functional/datasets/CreateDataset.test.ts (5.554 s) PASS test/unit/files/GetFileUserPermissions.test.ts PASS test/unit/files/UploadFile.test.ts PASS test/unit/users/GetCurrentAuthenticatedUser.test.ts PASS test/unit/files/GetFileDataTables.test.ts PASS test/unit/auth/Logout.test.ts PASS test/unit/datasets/GetAllDatasetPreviews.test.ts PASS test/unit/files/GetDatasetFiles.test.ts PASS test/unit/datasets/GetDatasetLocks.test.ts PASS test/unit/files/GetFileCitation.test.ts PASS test/unit/datasets/GetDatasetSummaryFieldNames.test.ts PASS test/unit/files/GetFileDownloadCount.test.ts PASS test/unit/datasets/GetDatasetCitation.test.ts PASS test/unit/info/GetMaxEmbargoDurationInMonths.test.ts PASS test/unit/files/DirectUploadClient.test.ts (6.145 s) PASS test/unit/info/GetZipDownloadLimit.test.ts

ReferenceError: You are trying to import a file after the Jest environment has been torn down. From test/unit/files/DirectUploadClient.test.ts.

  112 |           headers: {
  113 |             'Content-Type': 'application/octet-stream',
> 114 |             'Content-Length': fileSlice.size
      |                                                            ^
  115 |           },
  116 |           maxBodyLength: Infinity,
  117 |           maxContentLength: Infinity,

  at Object.<anonymous>.module.exports (node_modules/follow-redirects/debug.js:7:15)
  at Object.request (node_modules/follow-redirects/index.js:531:7)
  at dispatchHttpRequest (node_modules/axios/lib/adapters/http.js:455:21)
  at node_modules/axios/lib/adapters/http.js:143:5
  at wrapAsync (node_modules/axios/lib/adapters/http.js:123:10)
  at http (node_modules/axios/lib/adapters/http.js:161:10)
  at Axios.dispatchRequest (node_modules/axios/lib/core/dispatchRequest.js:51:10)
  at Axios._request (node_modules/axios/lib/core/Axios.js:173:33)
  at Axios.request (node_modules/axios/lib/core/Axios.js:40:25)
  at Axios.httpMethod [as put] (node_modules/axios/lib/core/Axios.js:212:19)
  at Function.wrap [as put] (node_modules/axios/lib/helpers/bind.js:5:15)
  at DirectUploadClient.<anonymous> (src/files/infra/clients/DirectUploadClient.ts:114:60)
  at src/files/infra/clients/DirectUploadClient.ts:31:71
  at Object.<anonymous>.__awaiter (src/files/infra/clients/DirectUploadClient.ts:27:12)
  at uploadPart (src/files/infra/clients/DirectUploadClient.ts:109:72)
  at DirectUploadClient.<anonymous> (src/files/infra/clients/DirectUploadClient.ts:136:31)
  at fulfilled (src/files/infra/clients/DirectUploadClient.ts:28:58)

PASS test/integration/collections/CollectionsRepository.test.ts (7.25 s) PASS test/functional/datasets/PublishDataset.test.ts (8.587 s) PASS test/integration/files/FilesRepository.test.ts (14.615 s) PASS test/integration/datasets/DatasetsRepository.test.ts (23.787 s) FAIL test/integration/files/DirectUploadClient.test.ts (37.865 s) ● DirectUploadClient › should upload file and add it to the dataset when there are multiple destination URLs

thrown: "Exceeded timeout of 25000 ms for a test.
Add a timeout value to this test to increase the timeout, if this is a long-running test. See https://jestjs.io/docs/api#testname-fn-timeout."

  123 |   })
  124 |
> 125 |   test('should upload file and add it to the dataset when there are multiple destination URLs', async () => {
      |   ^
  126 |     const destination = await createTestFileUploadDestination(
  127 |       multipartFile,
  128 |       testDataset2Ids.numericId

  at test/integration/files/DirectUploadClient.test.ts:125:3
  at Object.<anonymous> (test/integration/files/DirectUploadClient.test.ts:25:1)

Summary of all failing tests FAIL test/integration/files/DirectUploadClient.test.ts (37.865 s) ● DirectUploadClient › should upload file and add it to the dataset when there are multiple destination URLs

thrown: "Exceeded timeout of 25000 ms for a test.
Add a timeout value to this test to increase the timeout, if this is a long-running test. See https://jestjs.io/docs/api#testname-fn-timeout."

  123 |   })
  124 |
> 125 |   test('should upload file and add it to the dataset when there are multiple destination URLs', async () => {
      |   ^
  126 |     const destination = await createTestFileUploadDestination(
  127 |       multipartFile,
  128 |       testDataset2Ids.numericId

  at test/integration/files/DirectUploadClient.test.ts:125:3
  at Object.<anonymous> (test/integration/files/DirectUploadClient.test.ts:25:1)

Test Suites: 1 failed, 53 passed, 54 total Tests: 1 failed, 289 passed, 290 total Snapshots: 0 total Time: 38.322 s, estimated 57 s Ran all test suites. `

ekraffmiller avatar Jul 08 '24 16:07 ekraffmiller

The test passes for me as of 79398c8:

PASS test/integration/files/DirectUpload.test.ts (20.066 s)

pdurbin avatar Mar 21 '25 20:03 pdurbin

Related (duplicate?):

  • #179

pdurbin avatar Mar 21 '25 20:03 pdurbin

yep, duplicate, closing as it was solved in other PR.

g-saracca avatar Jun 04 '25 11:06 g-saracca