• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript jest-snapshot-serializer-raw.wrap函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中jest-snapshot-serializer-raw.wrap函数的典型用法代码示例。如果您正苦于以下问题:TypeScript wrap函数的具体用法?TypeScript wrap怎么用?TypeScript wrap使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了wrap函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: test

test('traverses directory tree up until it finds jest.config', () => {
  writeFiles(DIR, {
    '__tests__/a-banana.js': `
    const slash = require('slash');
    test('banana', () => expect(1).toBe(1));
    test('abc', () => console.log(slash(process.cwd())));
    `,
    'jest.config.js': `module.exports = {testRegex: '.*-banana.js'};`,
    'package.json': '{}',
    'some/nested/directory/file.js': '// nothing special',
  });

  const {stderr, status, stdout} = runJest(
    path.join(DIR, 'some', 'nested', 'directory'),
    ['-w=1', '--ci=false'],
    {skipPkgJsonCheck: true},
  );

  // Snapshot the console.loged `process.cwd()` and make sure it stays the same
  expect(
    wrap(stdout.replace(/^\W+(.*)e2e/gm, '<<REPLACED>>')),
  ).toMatchSnapshot();

  const {rest, summary} = extractSummary(stderr);
  expect(status).toBe(0);
  expect(wrap(rest)).toMatchSnapshot();
  expect(wrap(summary)).toMatchSnapshot();
});
开发者ID:Volune,项目名称:jest,代码行数:28,代码来源:jest.config.js.test.ts


示例2: it

  it('works with escaped regex', () => {
    // Write the first snapshot
    let result = runJest('snapshot-escape', [
      '-w=1',
      '--ci=false',
      'snapshotEscapeRegex.js',
    ]);
    let stderr = result.stderr;

    expect(stderr).toMatch('2 snapshots written from 1 test suite.');
    expect(result.status).toBe(0);
    expect(wrap(extractSummary(stderr).summary)).toMatchSnapshot();

    result = runJest('snapshot-escape', [
      '-w=1',
      '--ci=false',
      'snapshotEscapeRegex.js',
    ]);
    stderr = result.stderr;

    // Make sure we aren't writing a snapshot this time which would
    // indicate that the snapshot couldn't be loaded properly.
    expect(stderr).not.toMatch('Snapshot Summary');
    expect(wrap(extractSummary(stderr).summary)).toMatchSnapshot();
    expect(result.status).toBe(0);
  });
开发者ID:Volune,项目名称:jest,代码行数:26,代码来源:snapshot.test.ts


示例3: test

test('skips with expand arg', () => {
  const filename = 'skipsConstructs.test.js';
  const content = `
    it('it', () => {});
    xtest('xtest', () => {});
    xit('xit', () => {});
    it.skip('it.skip', () => {});
    test.skip('test.skip', () => {});

    xdescribe('xdescribe', () => {
      it('it', () => {});
      test('test', () => {});
    });

    describe.skip('describe.skip', () => {
      test('test', () => {});
      describe('describe', () => {
        test('test', () => {});
      });
    });
  `;

  writeFiles(TEST_DIR, {[filename]: content});
  const {stderr, status} = runJest(DIR, ['--expand']);
  expect(status).toBe(0);

  const {summary, rest} = extractSummary(stderr);
  expect(wrap(rest)).toMatchSnapshot();
  expect(wrap(summary)).toMatchSnapshot();
});
开发者ID:Volune,项目名称:jest,代码行数:30,代码来源:globals.test.ts


示例4: test

test('do not indent empty lines', () => {
  const filename = 'empty-line-indent.test.js';
  const template = makeTemplate(
    `test('inline snapshots', () => expect($1).toMatchInlineSnapshot());\n`,
  );

  {
    writeFiles(TESTS_DIR, {
      [filename]: template(['`hello\n\nworld`']),
    });
    const {stderr, status} = runJest(DIR, ['-w=1', '--ci=false', filename]);
    const fileAfter = readFile(filename);
    expect(stderr).toMatch('1 snapshot written from 1 test suite.');
    expect(status).toBe(0);
    expect(wrap(fileAfter)).toMatchSnapshot('initial write');
  }

  {
    const {stderr, status} = runJest(DIR, ['-w=1', '--ci=false', filename]);
    const fileAfter = readFile(filename);
    expect(stderr).toMatch('Snapshots:   1 passed, 1 total');
    expect(stderr).not.toMatch('1 snapshot written from 1 test suite.');
    expect(status).toBe(0);
    expect(wrap(fileAfter)).toMatchSnapshot('snapshot passed');
  }
});
开发者ID:facebook,项目名称:jest,代码行数:26,代码来源:toMatchInlineSnapshot.test.ts


示例5: test

test('console printing', () => {
  const {stderr, status} = runJest('console');
  const {summary, rest} = extractSummary(stderr);

  expect(status).toBe(0);
  expect(wrap(rest)).toMatchSnapshot();
  expect(wrap(summary)).toMatchSnapshot();
});
开发者ID:Volune,项目名称:jest,代码行数:8,代码来源:console.test.ts


示例6: test

test('handles property matchers', () => {
  const filename = 'handle-property-matchers.test.js';
  const template = makeTemplate(`test('handles property matchers', () => {
      expect({createdAt: $1}).toMatchInlineSnapshot({createdAt: expect.any(Date)});
    });
    `);

  {
    writeFiles(TESTS_DIR, {[filename]: template(['new Date()'])});
    const {stderr, status} = runJest(DIR, ['-w=1', '--ci=false', filename]);
    const fileAfter = readFile(filename);
    expect(stderr).toMatch('1 snapshot written from 1 test suite.');
    expect(status).toBe(0);
    expect(wrap(fileAfter)).toMatchSnapshot('initial write');
  }

  {
    const {stderr, status} = runJest(DIR, ['-w=1', '--ci=false', filename]);
    const fileAfter = readFile(filename);
    expect(stderr).toMatch('Snapshots:   1 passed, 1 total');
    expect(status).toBe(0);
    expect(wrap(fileAfter)).toMatchSnapshot('snapshot passed');
  }

  {
    writeFiles(TESTS_DIR, {
      [filename]: readFile(filename).replace('new Date()', '"string"'),
    });
    const {stderr, status} = runJest(DIR, ['-w=1', '--ci=false', filename]);
    const fileAfter = readFile(filename);
    expect(stderr).toMatch(
      'Received value does not match snapshot properties for "handles property matchers 1".',
    );
    expect(stderr).toMatch('Snapshots:   1 failed, 1 total');
    expect(status).toBe(1);
    expect(wrap(fileAfter)).toMatchSnapshot('snapshot failed');
  }

  {
    writeFiles(TESTS_DIR, {
      [filename]: readFile(filename).replace('any(Date)', 'any(String)'),
    });
    const {stderr, status} = runJest(DIR, [
      '-w=1',
      '--ci=false',
      filename,
      '-u',
    ]);
    const fileAfter = readFile(filename);
    expect(stderr).toMatch('1 snapshot updated from 1 test suite.');
    expect(status).toBe(0);
    expect(wrap(fileAfter)).toMatchSnapshot('snapshot updated');
  }
});
开发者ID:Volune,项目名称:jest,代码行数:54,代码来源:toMatchInlineSnapshot.test.ts



注:本文中的jest-snapshot-serializer-raw.wrap函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript jest-util.clearLine函数代码示例发布时间:2022-05-25
下一篇:
TypeScript jest-snapshot.SnapshotStateType类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap