adobe / aio-lib-files

An abstraction on top of cloud blob storage exposing a file system like API
https://www.adobe.io
Apache License 2.0
10 stars 14 forks source link

test failures with new joi@17.8.x dependency #107

Closed shazron closed 1 year ago

shazron commented 1 year ago

Workaround is to pin joi@17.7.1. 17.8.0 and 17.8.1 makes this fail.

 FAIL  test/init.test.js
  ● Test suite failed to run

    Cannot find module '@hapi/hoek/assert' from 'index.js'

      11 | */
      12 |
    > 13 | const TvmClient = require('@adobe/aio-lib-core-tvm')
         |                   ^
      14 | const logger = require('@adobe/aio-lib-core-logging')('@adobe/aio-lib-files', { provider: 'debug' })
      15 |
      16 | const utils = require('./utils')

      at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:259:17)
      at Object.<anonymous> (node_modules/joi/lib/index.js:3:16)
      at Object.<anonymous> (node_modules/@adobe/aio-lib-core-tvm/lib/TvmClient.js:13:13)
      at Object.<anonymous> (lib/init.js:13:19)
      at Object.<anonymous> (test/init.test.js:13:18)

 FAIL  test/Files.test.js
  ● Test suite failed to run

    Cannot find module '@hapi/hoek/assert' from 'index.js'

    However, Jest was able to find:
        '../lib/Files.js'

    You might want to include a file extension in your import, or update your 'moduleFileExtensions', which is currently ['js', 'json', 'jsx', 'ts', 'tsx', 'node'].

    See https://jestjs.io/docs/en/configuration#modulefileextensions-array-string

      13 | const upath = require('upath')
      14 | const fs = require('fs-extra')
    > 15 | const joi = require('joi')
         |             ^
      16 | const stream = require('stream')
      17 | const cloneDeep = require('lodash.clonedeep')
      18 | const logger = require('@adobe/aio-lib-core-logging')('@adobe/aio-lib-files', { provider: 'debug' })

      at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:259:17)
      at Object.<anonymous> (node_modules/joi/lib/index.js:3:16)
      at Object.<anonymous> (lib/Files.js:15:13)
      at Object.<anonymous> (test/Files.test.js:2:45)

 FAIL  test/impl/AzureBlobFiles.test.js
  ● Test suite failed to run

    Cannot find module '@hapi/hoek/assert' from 'index.js'

    However, Jest was able to find:
        '../../lib/impl/AzureBlobFiles.js'

    You might want to include a file extension in your import, or update your 'moduleFileExtensions', which is currently ['js', 'json', 'jsx', 'ts', 'tsx', 'node'].

    See https://jestjs.io/docs/en/configuration#modulefileextensions-array-string

      14 |
      15 | const azure = require('@azure/storage-blob')
    > 16 | const joi = require('joi')
         |             ^
      17 | const stream = require('stream')
      18 | const mime = require('mime-types')
      19 | const fetch = require('node-fetch')

      at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:259:17)
      at Object.<anonymous> (node_modules/joi/lib/index.js:3:16)
      at Object.<anonymous> (lib/impl/AzureBlobFiles.js:16:13)
      at Object.<anonymous> (test/impl/AzureBlobFiles.test.js:22:28)

--------------------|----------|----------|----------|----------|-------------------|
File                |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
--------------------|----------|----------|----------|----------|-------------------|
All files           |        0 |        0 |        0 |        0 |                   |
 lib                |        0 |        0 |        0 |        0 |                   |
  Files.js          |        0 |        0 |        0 |        0 |... 57,858,862,864 |
  FilesError.js     |        0 |        0 |        0 |        0 |... 48,49,50,51,53 |
  init.js           |        0 |        0 |        0 |        0 |... 64,66,67,68,76 |
  utils.js          |        0 |        0 |        0 |        0 |... 25,26,29,34,37 |
 lib/impl           |        0 |        0 |        0 |        0 |                   |
  AzureBlobFiles.js |        0 |        0 |        0 |        0 |... 26,628,638,642 |
--------------------|----------|----------|----------|----------|-------------------|
Jest: "global" coverage threshold for statements (100%) not met: 0%
Jest: "global" coverage threshold for branches (100%) not met: 0%
Jest: "global" coverage threshold for lines (100%) not met: 0%
Test Suites: 3 failed, 3 total
Tests:       0 total
Snapshots:   0 total
Time:        1.326s
Ran all test suites.
shazron commented 1 year ago

This is a module exports resolver issue with Jest. The issue is fixed by upgrading to jest@28 or greater.