Skip to content

Commit

Permalink
tests with no implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronabramov committed Sep 23, 2016
1 parent a5832d8 commit 65d9625
Show file tree
Hide file tree
Showing 6 changed files with 171 additions and 62 deletions.
56 changes: 47 additions & 9 deletions integration_tests/__tests__/__snapshots__/globals-test.js.snap
Original file line number Diff line number Diff line change
@@ -1,19 +1,57 @@
exports[`test global jest variables 1`] = `
" PASS __tests__/globals-test.js
✓ it.only
exports[`test basic test constructs 1`] = `
" PASS __tests__/basic-test-constructs-test.js
✓ it
✓ test
describe
✓ it
✓ test
Test Summary
› Ran all tests."
`;

exports[`test only 1`] = `
" PASS __tests__/only-constructs-test.js
✓ test.only
✓ it.only
✓ fit
○ it
○ test
○ it.skip
○ test.skip
○ xit
○ xtest
fdescribe
✓ it
✓ test
describe.only
✓ test
describe
describe
✓ test
Test Summary
› Ran all tests."
`;

exports[`test skips 1`] = `
" PASS __tests__/skips-constructs-test.js
✓ it
○ xtest
○ xit
○ it.skip
○ test.skip
xdescribe
○ it
○ test
describe.skip
○ test
describe
○ test
Test Summary
› Ran all tests."
`;

exports[`test tests with no implementation 1`] = `
" PASS __tests__/only-constructs-test.js
✓ it
○ it, no implementation
○ test, no implementation
Test Summary
› Ran all tests."
Expand Down
111 changes: 102 additions & 9 deletions integration_tests/__tests__/globals-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,114 @@
const path = require('path');
const runJest = require('../runJest');
const skipOnWindows = require('skipOnWindows');
const os = require('os');
const {createEmptyPackage, makeTests, cleanup} = require('../utils');

const DIR = path.resolve(os.tmpdir(), 'global-variables-test');
const TEST_DIR = path.resolve(DIR, '__tests__');

skipOnWindows.suite();

const dir = path.resolve(__dirname, '../globals');
const escapeOutput = string => string
.split('\n')
.slice(0, -2)
.join('\n')
.replace(/\s*\(.*ms\)/gm, '');

beforeEach(() => {
cleanup(DIR);
createEmptyPackage(DIR);
});

afterAll(() => cleanup(DIR));

test('basic test constructs', () => {
const filename = 'basic-test-constructs-test.js';
const content = `
it('it', () => {});
test('test', () => {});
describe('describe', () => {
it('it', () => {});
test('test', () => {});
});
`;

test('global jest variables', () => {
const {stderr, status} = runJest(dir);
makeTests(TEST_DIR, {[filename]: content});
const {stderr, status} = runJest(DIR);

expect(escapeOutput(stderr)).toMatchSnapshot();
expect(status).toBe(0);
});

test('skips', () => {
const filename = 'skips-constructs-test.js';
const content = `
it('it', () => {});
xtest('xtest', () => {});
xit('xit', () => {});
it.skip('it.skip', () => {});
test.skip('test.skip', () => {});
xdescribe('xdescribe', () => {
it('it', () => {});
test('test', () => {});
});
const output = stderr
.split('\n')
.slice(0, -2)
.join('\n')
.replace(/\s*\(.*ms\)/gm, '');
describe.skip('describe.skip', () => {
test('test', () => {});
describe('describe', () => {
test('test', () => {});
});
});
`;

expect(output).toMatchSnapshot();
makeTests(TEST_DIR, {[filename]: content});
const {stderr, status} = runJest(DIR);

expect(escapeOutput(stderr)).toMatchSnapshot();
expect(status).toBe(0);
});

test('only', () => {
const filename = 'only-constructs-test.js';
const content = `
it('it', () => {});
test.only('test.only', () => {});
it.only('it.only', () => {});
fit('fit', () => {});
fdescribe('fdescribe', () => {
it('it', () => {});
test('test', () => {});
});
describe.only('describe.only', () => {
test('test', () => {});
describe('describe', () => {
test('test', () => {});
});
});
`;

makeTests(TEST_DIR, {[filename]: content});
const {stderr, status} = runJest(DIR);

expect(escapeOutput(stderr)).toMatchSnapshot();
expect(status).toBe(0);
});

test('tests with no implementation', () => {
const filename = 'only-constructs-test.js';
const content = `
it('it', () => {});
it('it, no implementation');
test('test, no implementation');
`;

makeTests(TEST_DIR, {[filename]: content});
const {stderr, status} = runJest(DIR);

expect(escapeOutput(stderr)).toMatchSnapshot();
expect(status).toBe(0);
});
40 changes: 0 additions & 40 deletions integration_tests/globals/__tests__/globals-test.js

This file was deleted.

1 change: 0 additions & 1 deletion integration_tests/globals/package.json

This file was deleted.

21 changes: 19 additions & 2 deletions integration_tests/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,28 @@ const makeTests = (directory: string, tests: {[filename: string]: string}) => {
});
};

const createEmptyPackage = (directory, packageJson) => {
const DEFAULT_PACKAGE_JSON = {
description: 'THIS IS AN AUTOGENERATED FILE AND SHOULD NOT BE ADDED TO GIT',
jest: {
testEnvironment: 'node',
},
};

mkdirp.sync(directory);
packageJson || (packageJson = DEFAULT_PACKAGE_JSON);
fs.writeFileSync(
path.resolve(directory, 'package.json'),
JSON.stringify(packageJson, null, 2)
);
};

module.exports = {
cleanup,
makeTests,
makeTemplate,
createEmptyPackage,
fileExists,
linkJestPackage,
makeTemplate,
makeTests,
run,
};
4 changes: 3 additions & 1 deletion packages/jest-jasmine2/src/jasmine-async.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ function isPromise(obj) {
function promisifyIt(originalFn, env) {
return function(specName, fn, timeout) {
if (!fn) {
return null;
const spec = originalFn.call(env, specName);
spec.pend('not implemented');
return spec;
}

const isAsync = fn.length; // `done` was passed
Expand Down

0 comments on commit 65d9625

Please sign in to comment.