address icon indicating copy to clipboard operation
address copied to clipboard

address.mac returning undefined and tests failing

Open WeepingClown13 opened this issue 2 years ago • 3 comments

address.mac() method does not seem to work now and are returning undefined. I used the code samples from the repo readme itself to test them. And while running the tests, the tests that fetch mac address are failing because of this as well. Here is the log:

$ npm run test

> [email protected] pretest
> npm run lint -- --fix && npm run prepublishOnly


> [email protected] lint
> eslint src test --ext .ts --fix


> [email protected] prepublishOnly
> tshy && tshy-after


> [email protected] test
> egg-bin test



  test/address.test.ts
    regex check
      ✔ should MAC_IP_RE pass
      ✔ should MAC_RE pass
    address()
      ✔ should return first ethernet addresses
      ✔ should return first ethernet addresses from osx
      ✔ should return first ethernet addresses from linux
      ✔ should return first vnic interface addresses from osx
      ✔ should return first local loopback addresses
      ✔ should return first local loopback addresses from linux
    interface()
      ✔ should return interface with family
    address.mac()
      1) should return mac
      ✔ should return mock mac address
      ✔ should return null when ip not exists
      ✔ should return err when ifconfig cmd exec error
      ✔ should return mac mock win32
    address.ip()
      ✔ should return 127.0.0.1
      ✔ should return the first not 127.0.0.1 interface
      ✔ should return utun1
    address.dns()
      ✔ should return dns servers from osx
      ✔ should return dns servers from linux
      ✔ should return err when fs error

  test/promises.test.ts
    2) should address work
    3) should mac work
    ✔ should dns work

  test/ts.test.ts
    ✔ should works with ts without error (837ms)


  21 passing (889ms)
  3 failing

  1) test/address.test.ts
       address.mac()
         should return mac:
     AssertionError [ERR_ASSERTION]: undefined == true
      at file:///home/weepingclown/testjs/address/test/address.test.ts:130:9
      at Module.mac (file:///home/weepingclown/testjs/address/src/address.ts:188:12)
      at Context.<anonymous> (file:///home/weepingclown/testjs/address/test/address.test.ts:128:18)
      at processImmediate (node:internal/timers:476:21)

  2) test/promises.test.ts
       should address work:
     AssertionError [ERR_ASSERTION]: undefined == true
      at Context.<anonymous> (file:///home/weepingclown/testjs/address/test/promises.test.ts:9:5)

  3) test/promises.test.ts
       should mac work:
     AssertionError [ERR_ASSERTION]: null == true
      at Context.<anonymous> (file:///home/weepingclown/testjs/address/test/promises.test.ts:14:5)



[mochawesome] Report JSON saved to /home/weepingclown/testjs/address/node_modules/.mochawesome-reports/mochawesome.json

[mochawesome] Report HTML saved to /home/weepingclown/testjs/address/node_modules/.mochawesome-reports/mochawesome.html

ForkError: /home/weepingclown/testjs/address/node_modules/mocha/bin/_mocha --exit --timeout=60000 --reporter=/home/weepingclown/testjs/address/node_modules/mochawesome-with-mocha/src/mochawesome.js --reporter-options=reportDir=node_modules/.mochawesome-reports test/address.test.ts test/promises.test.ts test/ts.test.ts exit with code 1
    at ChildProcess.<anonymous> (/home/weepingclown/testjs/address/node_modules/egg-bin/src/cmd/base.ts:117:23)
    at Object.onceWrapper (node:events:632:26)
    at ChildProcess.emit (node:events:517:28)
    at ChildProcess.emit (node:domain:489:12)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:292:12) {
  code: 1
}

WeepingClown13 avatar Oct 05 '23 08:10 WeepingClown13

Can you show me the Node.js version?

fengmk2 avatar Oct 05 '23 14:10 fengmk2

Can you show me the Node.js version?

$ node -v
v18.18.0
$ npm -v
9.8.1

EDIT: Also confirmed with node v20.8.0 and npm v10.1.0

WeepingClown13 avatar Oct 05 '23 14:10 WeepingClown13

I can't get mac address too node -v v20.10.0

hungFight avatar Mar 29 '24 05:03 hungFight