How to use the jest-specific-snapshot.addSerializer function in jest-specific-snapshot

To help you get started, we’ve selected a few jest-specific-snapshot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github storybookjs / storybook / addons / storyshots / storyshots-core / src / frameworks / angular / renderTree.ts View on Github external
// eslint-disable-next-line import/no-extraneous-dependencies
import AngularSnapshotSerializer from 'jest-preset-angular/AngularSnapshotSerializer';
// eslint-disable-next-line import/no-extraneous-dependencies
import HTMLCommentSerializer from 'jest-preset-angular/HTMLCommentSerializer';
// eslint-disable-next-line import/no-extraneous-dependencies
import { TestBed } from '@angular/core/testing';
// eslint-disable-next-line import/no-extraneous-dependencies
import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
// eslint-disable-next-line import/no-extraneous-dependencies
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { addSerializer } from 'jest-specific-snapshot';
import { initModuleData } from './helpers';

addSerializer(HTMLCommentSerializer);
addSerializer(AngularSnapshotSerializer);

function getRenderedTree(story: any) {
  const currentStory = story.render();

  const { moduleMeta, AppComponent } = initModuleData(currentStory);

  TestBed.configureTestingModule(
    // TODO: take a look at `bootstrap` because it looks it does not exists in TestModuleMetadata
    {
      imports: [...moduleMeta.imports],
      declarations: [...moduleMeta.declarations],
      providers: [...moduleMeta.providers],
      schemas: [NO_ERRORS_SCHEMA, ...moduleMeta.schemas],
      bootstrap: [...moduleMeta.bootstrap],
    } as any
  );
github storybookjs / storybook / addons / storyshots / storyshots-core / src / frameworks / angular / renderTree.ts View on Github external
// eslint-disable-next-line import/no-extraneous-dependencies
import AngularSnapshotSerializer from 'jest-preset-angular/AngularSnapshotSerializer';
// eslint-disable-next-line import/no-extraneous-dependencies
import HTMLCommentSerializer from 'jest-preset-angular/HTMLCommentSerializer';
// eslint-disable-next-line import/no-extraneous-dependencies
import { TestBed } from '@angular/core/testing';
// eslint-disable-next-line import/no-extraneous-dependencies
import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
// eslint-disable-next-line import/no-extraneous-dependencies
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { addSerializer } from 'jest-specific-snapshot';
import { initModuleData } from './helpers';

addSerializer(HTMLCommentSerializer);
addSerializer(AngularSnapshotSerializer);

function getRenderedTree(story: any) {
  const currentStory = story.render();

  const { moduleMeta, AppComponent } = initModuleData(currentStory);

  TestBed.configureTestingModule(
    // TODO: take a look at `bootstrap` because it looks it does not exists in TestModuleMetadata
    {
      imports: [...moduleMeta.imports],
      declarations: [...moduleMeta.declarations],
      providers: [...moduleMeta.providers],
      schemas: [NO_ERRORS_SCHEMA, ...moduleMeta.schemas],
      bootstrap: [...moduleMeta.bootstrap],
    } as any
github Igorbek / typescript-plugin-styled-components / src / __tests__ / expectTransform.ts View on Github external
Source code:

${indent(obj.content)}

TypeScript before transform:

${indent(obj.source)}

TypeScript after transform:

${indent(obj.transformed)}

`
};

addSerializer(serializer);

export function expectTransform(transformer: ts.TransformerFactory, filename: string, path: string, outpath: string) {
    const content = fs.readFileSync(path + '/' + filename).toString();
    const sourceFile = ts.createSourceFile(filename, content, ts.ScriptTarget.Latest);
    const source = printer.printFile(sourceFile);
    const transformedFile = ts.transform(sourceFile, [transformer]).transformed[0];
    const transformed = printer.printFile(transformedFile);

    const snapshot: TransformBaseline = {
        type: 'transform-baseline',
        filename,
        content,
        source,
        transformed
    };
github atfzl / ReactUI / showcase / styled-components-source / __tests__ / expectTransform.ts View on Github external
Source code:

${indent(obj.content)}

TypeScript before transform:

${indent(obj.source)}

TypeScript after transform:

${indent(obj.transformed)}

`
};

addSerializer(serializer);

export function expectTransform(transformer: ts.TransformerFactory, filename: string, path: string, outpath: string) {
    const content = fs.readFileSync(path + '/' + filename).toString();
    const sourceFile = ts.createSourceFile(filename, content, ts.ScriptTarget.Latest);
    const source = printer.printFile(sourceFile);
    const transformedFile = ts.transform(sourceFile, [transformer]).transformed[0];
    const transformed = printer.printFile(transformedFile);

    const snapshot: TransformBaseline = {
        type: 'transform-baseline',
        filename,
        content,
        source,
        transformed
    };
github storybookjs / storybook / addons / storyshots / storyshots-core / src / api / snapshotsTestsTemplate.js View on Github external
snapshotSerializers.forEach(serializer => {
      addSerializer(serializer);
      expect.addSnapshotSerializer(serializer);
    });
  }

jest-specific-snapshot

[![CircleCI](https://circleci.com/gh/igor-dv/jest-specific-snapshot.svg?style=svg)](https://circleci.com/gh/igor-dv/jest-specific-snapshot)

MIT
Latest version published 2 years ago

Package Health Score

50 / 100
Full package analysis

Popular jest-specific-snapshot functions

Similar packages