After upgrading the library to version 4.0.1 there is an issue on our jest execution.
in case nothing is done or apply on our side
SyntaxError: Cannot use import statement outside a module
> 3 | import IPCIDR from 'ip-cidr';
in case library is added to transformIgnorePatterns, like transformIgnorePatterns: ['<rootDir>/node_modules/(?!(ip-cidr)/)',], the Address4 is not found due to import ipAddress from 'ip-address'; is a problem
TypeError: Cannot read properties of undefined (reading 'Address4')
833 | const erroredSubnets: ErroredSubnet[] = [];
834 |
> 835 | const startingIP = (cidr: string) => new IPCIDR(cidr).start().toString();
| ^
836 |
837 | const compareCidrs = (shouldInclude: boolean) => {
838 | if (shouldInclude) {
at Function.Address4 [as createAddress] (node_modules/ip-cidr/index.js:179:71)
at new createAddress (node_modules/ip-cidr/index.js:11:38)
in case dist file is used from moduleNameMapper like '^ip-cidr$': '<rootDir>/node_modules/ip-cidr/dist/ip-cidr.js',
TypeError: ip_cidr_1.default is not a constructor
833 | const erroredSubnets: ErroredSubnet[] = [];
834 |
> 835 | const startingIP = (cidr: string) => new IPCIDR(cidr).start().toString();
to mock the library was the only solution I found for being able to upgrade, like
and then '^ip-cidr$': '<rootDir>/__mocks__/ip-cidr-mock.ts', added to moduleNameMapper but this is not the right solution and could be very problematic in the future.
I guess library should be adapted to properly import ip-address library, right?
After upgrading the library to version
4.0.1
there is an issue on our jest execution.in case nothing is done or apply on our side
in case library is added to
transformIgnorePatterns
, liketransformIgnorePatterns: ['<rootDir>/node_modules/(?!(ip-cidr)/)',],
theAddress4
is not found due toimport ipAddress from 'ip-address';
is a problemin case dist file is used from
moduleNameMapper
like'^ip-cidr$': '<rootDir>/node_modules/ip-cidr/dist/ip-cidr.js',
to mock the library was the only solution I found for being able to upgrade, like
and then
'^ip-cidr$': '<rootDir>/__mocks__/ip-cidr-mock.ts',
added tomoduleNameMapper
but this is not the right solution and could be very problematic in the future.I guess library should be adapted to properly import ip-address library, right?