summaryrefslogtreecommitdiff
path: root/jest_resolver.js
blob: 6cbc1b9f18fe86765e0de8e5dc17be004e3afe5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
const fs = require('fs');

// Wrap jest default resolver to detect missing frontend fixtures.
module.exports = (request, options) => {
  try {
    return options.defaultResolver(request, options);
  } catch (e) {
    if (request.match(/tmp\/tests\/frontend\/fixtures/) && !fs.existsSync(request)) {
      console.error(
        '\x1b[1m\x1b[41m\x1b[30m %s \x1b[0m %s',
        '!',
        `Fixture file ${request} does not exist. Did you run bin/rake frontend:fixtures?`,
      );
    }
    throw e;
  }
};