本文整理汇总了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;未经允许,请勿转载。 |
请发表评论