Skip to content

Commit

Permalink
(refactor): rename tests -> e2e, integration-tests -> integration
Browse files Browse the repository at this point in the history
- change testDir in tests to the new names
- reword docs and scripts so they handle this properly

(refactor): interpolate directory in the lint tests
- DRY up so don't have to change all these lines when the path is
  a constant
  • Loading branch information
agilgur5 committed Mar 27, 2020
1 parent 1e690b5 commit 70c8c68
Show file tree
Hide file tree
Showing 42 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -24,7 +24,7 @@
"prepare": "tsc -p tsconfig.json",
"build": "tsc -p tsconfig.json",
"lint": "yarn build && yarn lint:post-build",
"lint:post-build": "node dist/index.js lint src test --ignore-pattern 'test/tests/lint'",
"lint:post-build": "node dist/index.js lint src test --ignore-pattern 'test/e2e/lint'",
"test": "yarn build && yarn test:post-build",
"test:post-build": "node dist/index.js test",
"start": "tsc -p tsconfig.json --watch",
Expand Down
4 changes: 2 additions & 2 deletions test/README.md
Expand Up @@ -2,5 +2,5 @@

There are two main directories here:

- `tests` contains end-to-end (E2E) tests of the CLI
- `integration-tests` contains tests ensuring that common or recommended plugins work properly together with TSDX
- `e2e` contains end-to-end (E2E) tests of the CLI
- `integration` contains tests ensuring that common or recommended plugins work properly together with TSDX
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Expand Up @@ -8,39 +8,41 @@ const util = require('../../utils/fixture');

shell.config.silent = true;

const testDir = 'tests';
const testDir = 'e2e';
const stageName = 'stage-lint';

const lintDir = `test/${testDir}/lint`

describe('tsdx lint', () => {
it('should fail to lint a ts file with errors', () => {
const testFile = 'test/tests/lint/file-with-lint-errors.ts';
const testFile = `${lintDir}/file-with-lint-errors.ts`;
const output = shell.exec(`node dist/index.js lint ${testFile}`);
expect(output.code).toBe(1);
expect(output.stdout.includes('Parsing error:')).toBe(true);
});

it('should succeed linting a ts file without errors', () => {
const testFile = 'test/tests/lint/file-without-lint-error.ts';
const testFile = `${lintDir}/file-without-lint-error.ts`;
const output = shell.exec(`node dist/index.js lint ${testFile}`);
expect(output.code).toBe(0);
});

it('should fail to lint a ts file with prettier errors', () => {
const testFile = 'test/tests/lint/file-with-prettier-lint-errors.ts';
const testFile = `${lintDir}/file-with-prettier-lint-errors.ts`;
const output = shell.exec(`node dist/index.js lint ${testFile}`);
expect(output.code).toBe(1);
expect(output.stdout.includes('prettier/prettier')).toBe(true);
});

it('should fail to lint a tsx file with errors', () => {
const testFile = 'test/tests/lint/react-file-with-lint-errors.tsx';
const testFile = `${lintDir}/react-file-with-lint-errors.tsx`;
const output = shell.exec(`node dist/index.js lint ${testFile}`);
expect(output.code).toBe(1);
expect(output.stdout.includes('Parsing error:')).toBe(true);
});

it('should succeed linting a tsx file without errors', () => {
const testFile = 'test/tests/lint/react-file-without-lint-error.tsx';
const testFile = `${lintDir}/react-file-without-lint-error.tsx`;
const output = shell.exec(`node dist/index.js lint ${testFile}`);
expect(output.code).toBe(0);
});
Expand Down
Expand Up @@ -4,7 +4,7 @@ const { execWithCache } = require('../utils/shell');

shell.config.silent = false;

const testDir = 'tests';
const testDir = 'e2e';
const fixtureName = 'build-default';
const stageName = `stage-${fixtureName}`;

Expand Down
Expand Up @@ -4,7 +4,7 @@ const { execWithCache } = require('../utils/shell');

shell.config.silent = false;

const testDir = 'tests';
const testDir = 'e2e';
const fixtureName = 'build-invalid';
const stageName = `stage-${fixtureName}`;

Expand Down
Expand Up @@ -4,7 +4,7 @@ const { execWithCache } = require('../utils/shell');

shell.config.silent = false;

const testDir = 'tests';
const testDir = 'e2e';
const fixtureName = 'build-withTsconfig';
const stageName = `stage-${fixtureName}`;

Expand Down
File renamed without changes.
File renamed without changes.
Expand Up @@ -5,7 +5,7 @@ const { execWithCache } = require('../utils/shell');

shell.config.silent = false;

const testDir = 'integration-tests';
const testDir = 'integration';
const fixtureName = 'build-options';
const stageName = `stage-integration-${fixtureName}`;

Expand Down
Expand Up @@ -6,7 +6,7 @@ const { execWithCache } = require('../utils/shell');

shell.config.silent = false;

const testDir = 'integration-tests';
const testDir = 'integration';
const fixtureName = 'build-withConfig';
const stageName = `stage-integration-${fixtureName}`;

Expand Down

0 comments on commit 70c8c68

Please sign in to comment.