node-modules / address

Get current machine IP and MAC address.
Other
233 stars 32 forks source link

address.mac returning undefined and tests failing #38

Open WeepingClown13 opened 10 months ago

WeepingClown13 commented 10 months ago

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

> address@2.0.1 pretest
> npm run lint -- --fix && npm run prepublishOnly

> address@2.0.1 lint
> eslint src test --ext .ts --fix

> address@2.0.1 prepublishOnly
> tshy && tshy-after

> address@2.0.1 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
}
fengmk2 commented 10 months ago

Can you show me the Node.js version?

WeepingClown13 commented 10 months ago

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

hungFight commented 4 months ago

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