function getSnowpackPluginOutputSnapshotSerializer(basePath) {
  return {
    serialize(value) {
      if (value.getMockName() === 'console.log') {
        return value.mock.calls
          .map(toSingleArgument)
          .map(toNoralizedByteSize)
          .map(removeColors)
          .join('\n');
      }

      const calls = value.mock.calls
        .filter(isLocal)
        .map(toPathAndStringContent.bind(null, basePath));
      return calls
        .sort((a, b) => {
          return a[0] < b[0] ? -1 : 1;
        })
        .map(([path, content]) => {
          return `FILE: ${path}\n${content}`;
        })
        .join(
          '\n\n--------------------------------------------------------------------------------\n\n',
        );
    },

    test(value) {
      return value && value.mock;
    },
  };
}
Serializer of written files as well as console.log output.

Both file contents and log output is normalized to account for differences
in UNIX and Windows systems.

@param string basePath all files written outside this path will be ignored (usually set to __dirname)