#1009572 node-cache-loader: FTBFS: dh_auto_test: error: /bin/sh -ex debian/tests/pkg-js/test returned exit code 1

Package:
jest
Source:
node-jest
Submitter:
Lucas Nussbaum
Date:
2022-07-20 09:15:14 UTC
Severity:
important
Tags:
#1009572#5
Date:
2022-04-12 19:21:48 UTC
From:
To:
Hi,

During a rebuild of all packages in sid, your package failed to build
on amd64.


Relevant part (hopefully):
The full build log is available from:
http://qa-logs.debian.net/2022/04/12/node-cache-loader_4.1.0+~cs2.0.0-2_unstable.log

All bugs filed during this archive rebuild are listed at:
https://bugs.debian.org/cgi-bin/pkgreport.cgi?tag=ftbfs-20220412;users=lucas@debian.org
or:
https://udd.debian.org/bugs/?release=na&merged=ign&fnewerval=7&flastmodval=7&fusertag=only&fusertagtag=ftbfs-20220412&fusertaguser=lucas@debian.org&allbugs=1&cseverity=1&ctags=1&caffected=1#results

A list of current common problems and possible solutions is available at
http://wiki.debian.org/qa.debian.org/FTBFS . You're welcome to contribute!

If you reassign this bug to another package, please marking it as 'affects'-ing
this package. See https://www.debian.org/Bugs/server-control#affects

If you fail to reproduce this, please provide a build log and diff it with mine
so that we can identify if something relevant changed in the meantime.

#1009572#18
Date:
2022-04-24 05:46:55 UTC
From:
To:
To facilitate ES transition, we built some hybrid modules (node-find-up
for example):
  * package.json#exports#require exposes old & new API
  * package.json#exports#import exposes new API

The reported error shows Jest resolver behavior:

 > FAIL test/cjs.test.js
 >   ● Test suite failed to run
 >
 >     TypeError: findUp.sync is not a function
 >
 >       11 |
 >       12 | module.exports.sync = cwd => {
 >     > 13 | 	const filePath = findUp.sync('package.json', {cwd});
 >          | 	                        ^
 >       14 | 	return filePath && path.dirname(filePath);
 >       15 | };
 >       16 |

Jest does not use Node.js resolver but jest-resolver instead. Here,
jest-resolver uses find-up/index.js instead of find-up/index.cjs and
then does not find old API functions.

Here is a workaround:
  * patch package.json to add: "jest": {"resolver":"debian/resolver.js"},
  * write the resolver:

$ cat > debian/resolver.js << EOF
module.exports = (request, options) => {
   // use defaultResolver
   return options.defaultResolver(request, {
     ...options,
     // use packageFilter to modify `package.json` before resolution
     // (see https://www.npmjs.com/package/resolve#resolveid-opts-cb)
     packageFilter: (pkg) => {
       let main = pkg.exports && pkg.exports.require ?
pkg.exports.require : pkg.main;
       return {
         ...pkg,
         // change `main` value
         main: main
       };
     },
   });
};
EOF

#1009572#29
Date:
2022-07-20 09:11:31 UTC
From:
To:

#1009572#30
Date:
2022-07-20 09:13:03 UTC
From:
To: