Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ekraffmiller opened this issue Jul 8, 2024 · 0 comments

Comments

@ekraffmiller
Copy link
Contributor

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

js-dataverse@2.0.0 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.
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant