Skip to content

ReferenceError: You are trying to import a file after the Jest environment has been torn down. From test/cli/scan.spec.ts. #46

@ahtrotta

Description

@ahtrotta

To reproduce: in appmap-js, run the following command from packages/scanner:

npx appmap-node@latest yarn test scan.spec.ts

I get the following output:

(Λ) Running with appmap-node version 2.5.1
(Λ) Detected Jest. Tests will be automatically recorded.
  console.log
    Using scanner configuration file /home/ahtrotta/projects/appmap/appmap-js/packages/scanner/src/sampleConfig/default.yml

      at src/configuration/configurationProvider.ts:408:15

  console.log
    scanning /home/ahtrotta/projects/appmap/appmap-js/packages/scanner/test/fixtures/appmaps/org_springframework_samples_petclinic_owner_OwnerControllerTests_testInitCreationForm.appmap.json

      at src/cli/scan.ts:320:19
          at Array.map (<anonymous>)

  console.log
    undefined

      at src/cli/scan/singleScan.ts:93:15

  console.log
    undefined

      at src/report/summaryReport.ts:105:13

  console.log
    0 findings (0 unique)

      at src/report/summaryReport.ts:106:13

  console.log


      at src/cli/scan/singleScan.ts:95:15

  console.log
    Performed 13 checks in 244ms (53 checks/sec)

      at src/cli/scan/singleScan.ts:98:15

  console.log
    Using scanner configuration file /home/ahtrotta/projects/appmap/appmap-js/packages/scanner/src/sampleConfig/default.yml

      at src/configuration/configurationProvider.ts:408:15

  console.log
    scanning /tmp/tmp-35574-bzQdD1iKYjAn/bad.appmap.json

      at src/cli/scan.ts:320:19
          at Array.map (<anonymous>)

  console.log
    scanning /tmp/tmp-35574-bzQdD1iKYjAn/good.appmap.json

      at src/cli/scan.ts:320:19
          at Array.map (<anonymous>)

  console.warn
    Error: Error processing "/tmp/tmp-35574-bzQdD1iKYjAn/bad.appmap.json"
        at /home/ahtrotta/projects/appmap/appmap-js/packages/scanner/src/cli/scan.ts:335:23
        at Generator.next (<anonymous>)
        at fulfilled (/home/ahtrotta/projects/appmap/appmap-js/packages/scanner/src/cli/scan.ts:228:24) {
      [cause]: SyntaxError: Unexpected token b in JSON at position 0
          at JSON.parse (<anonymous>)
          at Ee.source (/home/ahtrotta/projects/appmap/appmap-js/packages/models/src/appMapBuilder/index.js:37:24)
          at new Ee (/home/ahtrotta/projects/appmap/appmap-js/packages/models/src/appMapBuilder/index.js:27:12)
          at D (/home/ahtrotta/projects/appmap/appmap-js/packages/models/src/appMapBuilder/index.js:281:10)
          at /home/ahtrotta/projects/appmap/appmap-js/packages/scanner/src/cli/scan.ts:322:51
          at Generator.next (<anonymous>)
          at fulfilled (/home/ahtrotta/projects/appmap/appmap-js/packages/scanner/src/cli/scan.ts:228:24)
    }



      at src/cli/scan.ts:339:19
      at fulfilled (src/cli/scan.ts:228:24)

  console.log
    undefined

      at src/cli/scan/singleScan.ts:93:15

  console.log
    undefined

      at src/report/summaryReport.ts:105:13

  console.log
    0 findings (0 unique)

      at src/report/summaryReport.ts:106:13

  console.log


      at src/cli/scan/singleScan.ts:95:15

  console.log
    Performed 13 checks in 179ms (72 checks/sec)

      at src/cli/scan/singleScan.ts:98:15

  console.log
    Using scanner configuration file /home/ahtrotta/projects/appmap/appmap-js/packages/scanner/src/sampleConfig/default.yml

      at src/configuration/configurationProvider.ts:408:15

  console.log
    scanning /tmp/tmp-35574-DGdjZ3X38gpt/bad.appmap.json

      at src/cli/scan.ts:320:19
          at Array.map (<anonymous>)

  console.warn
    Error: Error processing "/tmp/tmp-35574-DGdjZ3X38gpt/bad.appmap.json"
        at /home/ahtrotta/projects/appmap/appmap-js/packages/scanner/src/cli/scan.ts:335:23
        at Generator.next (<anonymous>)
        at fulfilled (/home/ahtrotta/projects/appmap/appmap-js/packages/scanner/src/cli/scan.ts:228:24) {
      [cause]: SyntaxError: Unexpected token b in JSON at position 0
          at JSON.parse (<anonymous>)
          at Ee.source (/home/ahtrotta/projects/appmap/appmap-js/packages/models/src/appMapBuilder/index.js:37:24)
          at new Ee (/home/ahtrotta/projects/appmap/appmap-js/packages/models/src/appMapBuilder/index.js:27:12)
          at D (/home/ahtrotta/projects/appmap/appmap-js/packages/models/src/appMapBuilder/index.js:281:10)
          at /home/ahtrotta/projects/appmap/appmap-js/packages/scanner/src/cli/scan.ts:322:51
          at Generator.next (<anonymous>)
          at fulfilled (/home/ahtrotta/projects/appmap/appmap-js/packages/scanner/src/cli/scan.ts:228:24)
    }



      at src/cli/scan.ts:339:19
      at fulfilled (src/cli/scan.ts:228:24)

  console.log
    Using scanner configuration file /home/ahtrotta/projects/appmap/appmap-js/packages/scanner/src/sampleConfig/default.yml

      at src/configuration/configurationProvider.ts:408:15

  console.log
    scanning /tmp/tmp-35574-CSmH6LBiPruP

      at src/cli/scan.ts:320:19
          at Array.map (<anonymous>)

  console.log
    scanning /home/ahtrotta/projects/appmap/appmap-js/packages/scanner/test/fixtures/appmaps/org_springframework_samples_petclinic_owner_OwnerControllerTests_testInitCreationForm.appmap.json

      at src/cli/scan.ts:320:19
          at Array.map (<anonymous>)

  console.log
    Using scanner configuration file /tmp/OVzM86/appmap-scanner.yml

      at src/configuration/configurationProvider.ts:408:15

  console.log
    scanning /tmp/OVzM86/Confirmation_already_confirmed_user_should_not_be_able_to_confirm_the_account_again.appmap.json

      at src/cli/scan.ts:320:19
          at Array.map (<anonymous>)

  console.log
    Using scanner configuration file /tmp/1gIfS6/appmap-scanner.yml

      at src/configuration/configurationProvider.ts:408:15

  console.log
    scanning /tmp/1gIfS6/Confirmation_already_confirmed_user_should_not_be_able_to_confirm_the_account_again.appmap.json

      at src/cli/scan.ts:320:19
          at Array.map (<anonymous>)

  console.log
    Using scanner configuration file /tmp/0ZETs8/appmap-scanner.yml

      at src/configuration/configurationProvider.ts:408:15

  console.warn
    Error: ENOSPC: System limit for number of file watchers reached
        at /home/ahtrotta/projects/appmap/appmap-js/packages/scanner/test/cli/scan.spec.ts:767:21
        at Generator.next (<anonymous>)
        at fulfilled (/home/ahtrotta/projects/appmap/appmap-js/packages/scanner/test/cli/scan.spec.ts:490:24)



      at Watcher.<anonymous> (src/cli/scan/watchScan.ts:406:19)
      at Object.<anonymous>.__awaiter (src/cli/scan/watchScan.ts:302:67)
      at src/cli/scan/watchScan.ts:284:10
      at Watcher.<anonymous> (src/cli/scan/watchScan.ts:404:14)
      at Watcher.record (../../../../../.npm/_npx/a04c6870cebb0c63/node_modules/appmap-node/src/recorder.ts:31:24)
      at Watcher.watcherErrorFunction (src/cli/scan/watchScan.ts:402:36)
      at test/cli/scan.spec.ts:769:23
      at fulfilled (test/cli/scan.spec.ts:490:24)

  console.warn
    Will disable file watching. File polling will stay enabled.



      at Watcher.<anonymous> (src/cli/scan/watchScan.ts:407:19)
      at Object.<anonymous>.__awaiter (src/cli/scan/watchScan.ts:302:67)
      at src/cli/scan/watchScan.ts:284:10
      at Watcher.<anonymous> (src/cli/scan/watchScan.ts:404:14)
      at Watcher.record (../../../../../.npm/_npx/a04c6870cebb0c63/node_modules/appmap-node/src/recorder.ts:31:24)
      at Watcher.watcherErrorFunction (src/cli/scan/watchScan.ts:402:36)
      at test/cli/scan.spec.ts:769:23
      at fulfilled (test/cli/scan.spec.ts:490:24)

  console.warn
    File watching disabled.



      at Watcher.<anonymous> (src/cli/scan/watchScan.ts:410:19)
      at fulfilled (src/cli/scan/watchScan.ts:287:24)

  console.log
    Using scanner configuration file /tmp/wA2s79/appmap-scanner.yml

      at src/configuration/configurationProvider.ts:408:15

  console.log
    scanning /tmp/wA2s79/Confirmation_already_confirmed_user_should_not_be_able_to_confirm_the_account_again.appmap.json

      at src/cli/scan.ts:320:19
          at Array.map (<anonymous>)

  console.log
    Using scanner configuration file /tmp/nrjzsa/appmap-scanner.yml

      at src/configuration/configurationProvider.ts:408:15

  console.log
    scanning /tmp/nrjzsa/Confirmation_already_confirmed_user_should_not_be_able_to_confirm_the_account_again.appmap.json

      at src/cli/scan.ts:320:19
          at Array.map (<anonymous>)

  console.log
    Using scanner configuration file /tmp/MHwPo7/appmap-scanner.yml

      at src/configuration/configurationProvider.ts:408:15

  console.log
    scanning /tmp/MHwPo7/Confirmation_already_confirmed_user_should_not_be_able_to_confirm_the_account_again.appmap.json

      at src/cli/scan.ts:320:19
          at Array.map (<anonymous>)

  console.log
    Using scanner configuration file /tmp/MHwPo7/appmap-scanner.yml

      at src/configuration/configurationProvider.ts:408:15

  console.log
    scanning /tmp/MHwPo7/Confirmation_already_confirmed_user_should_not_be_able_to_confirm_the_account_again.appmap.json

      at src/cli/scan.ts:320:19
          at Array.map (<anonymous>)

  console.log
    Using scanner configuration file /tmp/44FzH6/appmap-scanner.yml

      at src/configuration/configurationProvider.ts:408:15

  console.log
    scanning /tmp/44FzH6/Confirmation_already_confirmed_user_should_not_be_able_to_confirm_the_account_again.appmap.json

      at src/cli/scan.ts:320:19
          at Array.map (<anonymous>)

  console.log
    scanning /tmp/44FzH6/Confirmation_already_confirmed_user_should_not_be_able_to_confirm_the_account_again.appmap.json

      at src/cli/scan.ts:320:19
          at Array.map (<anonymous>)

  console.log
    Using scanner configuration file /tmp/qSMTx7/appmap-scanner.yml

      at src/configuration/configurationProvider.ts:408:15

  console.log
    scanning /tmp/qSMTx7/Confirmation_already_confirmed_user_should_not_be_able_to_confirm_the_account_again.appmap.json

      at src/cli/scan.ts:320:19
          at Array.map (<anonymous>)

  console.log
    scanning /tmp/qSMTx7/other.appmap.json

      at src/cli/scan.ts:320:19
          at Array.map (<anonymous>)

[scan] Report file /tmp/qSMTx7/Confirmation_already_confirmed_user_should_not_be_able_to_confirm_the_account_again/appmap-findings.json is already up to date
[scan] Report file /tmp/qSMTx7/other/appmap-findings.json is already up to date
  console.log
    scanning /tmp/qSMTx7/test-0.appmap.json

      at src/cli/scan.ts:320:19
          at Array.map (<anonymous>)

  console.log
    scanning /tmp/qSMTx7/test-1.appmap.json

      at src/cli/scan.ts:320:19
          at Array.map (<anonymous>)

 FAIL  test/cli/scan.spec.ts
  ● Test suite failed to run

    TypeError: Cannot convert undefined or null to object
        at Function.entries (<anonymous>)

      at pick (../../../../../.npm/_npx/a04c6870cebb0c63/node_modules/appmap-node/src/util/pick.ts:5:27)
      at exceptionMetadata (../../../../../.npm/_npx/a04c6870cebb0c63/node_modules/appmap-node/src/metadata.ts:31:14)
      at extractTestError (../../../../../.npm/_npx/a04c6870cebb0c63/node_modules/appmap-node/src/hooks/jest.ts:86:36)
      at eventHandler (../../../../../.npm/_npx/a04c6870cebb0c63/node_modules/appmap-node/src/hooks/jest.ts:56:38)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        28.59 s
Ran all test suites matching /scan.spec.ts/i.

ReferenceError: You are trying to `import` a file after the Jest environment has been torn down. From test/cli/scan.spec.ts.



      at src/configuration/configurationProvider.ts:257:68

ReferenceError: You are trying to `import` a file after the Jest environment has been torn down. From test/cli/scan.spec.ts.



      at src/configuration/configurationProvider.ts:272:69

ReferenceError: You are trying to `import` a file after the Jest environment has been torn down. From test/cli/scan.spec.ts.



      at src/configuration/configurationProvider.ts:257:68

ReferenceError: You are trying to `import` a file after the Jest environment has been torn down. From test/cli/scan.spec.ts.



      at src/configuration/configurationProvider.ts:257:68

ReferenceError: You are trying to `import` a file after the Jest environment has been torn down. From test/cli/scan.spec.ts.



      at src/configuration/configurationProvider.ts:272:69

ReferenceError: You are trying to `import` a file after the Jest environment has been torn down. From test/cli/scan.spec.ts.



      at src/configuration/configurationProvider.ts:257:68

ReferenceError: You are trying to `import` a file after the Jest environment has been torn down. From test/cli/scan.spec.ts.



      at src/configuration/configurationProvider.ts:257:68

ReferenceError: You are trying to `import` a file after the Jest environment has been torn down. From test/cli/scan.spec.ts.



      at src/configuration/configurationProvider.ts:257:68

ReferenceError: You are trying to `import` a file after the Jest environment has been torn down. From test/cli/scan.spec.ts.



      at src/configuration/configurationProvider.ts:257:68

ReferenceError: You are trying to `import` a file after the Jest environment has been torn down. From test/cli/scan.spec.ts.



      at src/configuration/configurationProvider.ts:272:69

ReferenceError: You are trying to `import` a file after the Jest environment has been torn down. From test/cli/scan.spec.ts.



      at src/configuration/configurationProvider.ts:257:68

ReferenceError: You are trying to `import` a file after the Jest environment has been torn down. From test/cli/scan.spec.ts.



      at src/configuration/configurationProvider.ts:272:69

ReferenceError: You are trying to `import` a file after the Jest environment has been torn down. From test/cli/scan.spec.ts.



      at src/configuration/configurationProvider.ts:257:68

ReferenceError: You are trying to `import` a file after the Jest environment has been torn down. From test/cli/scan.spec.ts.



      at src/configuration/configurationProvider.ts:277:65

ReferenceError: You are trying to `import` a file after the Jest environment has been torn down. From test/cli/scan.spec.ts.



      at src/configuration/configurationProvider.ts:277:65

ReferenceError: You are trying to `import` a file after the Jest environment has been torn down. From test/cli/scan.spec.ts.



      at src/configuration/configurationProvider.ts:277:65

ReferenceError: You are trying to `import` a file after the Jest environment has been torn down. From test/cli/scan.spec.ts.



      at src/configuration/configurationProvider.ts:277:65

ReferenceError: You are trying to `import` a file after the Jest environment has been torn down. From test/cli/scan.spec.ts.



      at src/configuration/configurationProvider.ts:284:68
  console.warn
    Problem processing /tmp/qSMTx7/test-2/mtime:
     TypeError: rule.Options is not a constructor
        at /home/ahtrotta/projects/appmap/appmap-js/packages/scanner/src/configuration/configurationProvider.ts:317:19
        at Generator.next (<anonymous>)
        at fulfilled (/home/ahtrotta/projects/appmap/appmap-js/packages/scanner/src/configuration/configurationProvider.ts:211:24)



      at src/cli/scan/watchScan.ts:358:49
      at ../../node_modules/async/dist/async.js:1496:46
          at Array.forEach (<anonymous>)
      at trigger (../../node_modules/async/dist/async.js:1496:27)
      at ../../node_modules/async/dist/async.js:1560:25
      at ../../node_modules/async/dist/async.js:327:20

  console.warn
    Problem processing /tmp/qSMTx7/test-3/mtime:
     TypeError: rule.Options is not a constructor
        at /home/ahtrotta/projects/appmap/appmap-js/packages/scanner/src/configuration/configurationProvider.ts:317:19
        at Generator.next (<anonymous>)
        at fulfilled (/home/ahtrotta/projects/appmap/appmap-js/packages/scanner/src/configuration/configurationProvider.ts:211:24)



      at src/cli/scan/watchScan.ts:358:49
      at ../../node_modules/async/dist/async.js:1496:46
          at Array.forEach (<anonymous>)
      at trigger (../../node_modules/async/dist/async.js:1496:27)
      at ../../node_modules/async/dist/async.js:1560:25
      at ../../node_modules/async/dist/async.js:327:20

  console.warn
    Problem processing /tmp/qSMTx7/test-4/mtime:
     TypeError: rule.Options is not a constructor
        at /home/ahtrotta/projects/appmap/appmap-js/packages/scanner/src/configuration/configurationProvider.ts:317:19
        at Generator.next (<anonymous>)
        at fulfilled (/home/ahtrotta/projects/appmap/appmap-js/packages/scanner/src/configuration/configurationProvider.ts:211:24)



      at src/cli/scan/watchScan.ts:358:49
      at ../../node_modules/async/dist/async.js:1496:46
          at Array.forEach (<anonymous>)
      at trigger (../../node_modules/async/dist/async.js:1496:27)
      at ../../node_modules/async/dist/async.js:1560:25
      at ../../node_modules/async/dist/async.js:327:20

[scan] Report file /tmp/qSMTx7/Confirmation_already_confirmed_user_should_not_be_able_to_confirm_the_account_again/appmap-findings.json is already up to date
[scan] Report file /tmp/qSMTx7/other/appmap-findings.json is already up to date

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingreleased

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions