Skip to content

Commit

Permalink
chore: configure global types for jest
Browse files Browse the repository at this point in the history
Using configuration suggested by `jest-extended`.
https://github.com/jest-community/jest-extended#typescript

Added `cross-env` to support cross-platform environment variables.
  • Loading branch information
jdanil committed Apr 29, 2020
1 parent a25d214 commit 85c33d0
Show file tree
Hide file tree
Showing 15 changed files with 13 additions and 15 deletions.
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
"scripts": {
"clean": "rm -rf node_modules/.cache && rm -rf test/dead-code-elimination/dist && rm -f test/dead-code-elimination/tsconfig.tsbuildinfo && workspaces-run -- rm -rf dist -- rm -f tsconfig.tsbuildinfo -- rm -f tsconfig.browser.tsbuildinfo",
"start": "yarn build:main && npx nodemon --exec \"start-storybook -p 6006 --ci\" --watch packages/ts-transform/ -e tsx",
"start:prod": "NODE_ENV=production yarn start",
"start:prod": "cross-env NODE_ENV=production yarn start",
"start:inspect": "npx nodemon --exec \"node --inspect-brk node_modules/.bin/start-storybook -p 6006 --ci\" --watch packages/ts-transform/ -e tsx",
"test": "yarn build:main && jest --no-cache",
"test:watch": "yarn build:main && jest --no-cache --watch",
"test:cover": "yarn test --collectCoverage",
"lint": "eslint --config .eslintrc.js --ext tsx,ts ./packages/**/src ./examples",
"lint:fix": "yarn lint -- --fix",
"build": "yarn build:main && yarn build:browser",
"build:main": "TYPEOF_WINDOW='typeof window' ttsc --build packages/tsconfig.json",
"build:main": "cross-env TYPEOF_WINDOW=\"typeof window\" ttsc --build packages/tsconfig.json",
"build:dead-code-elimination": "cd test/dead-code-elimination && ttsc",
"build:browser": "TYPEOF_WINDOW='\"object\"' ttsc --build packages/tsconfig.browser.json",
"build:browser": "cross-env TYPEOF_WINDOW='\"object\"' ttsc --build packages/tsconfig.browser.json",
"build:inspect": "node --inspect-brk node_modules/typescript/lib/tsc.js --build packages",
"build-storybook": "build-storybook",
"preversion": "yarn clean && yarn build && yarn test",
Expand All @@ -43,6 +43,7 @@
"@typescript-eslint/eslint-plugin": "^2.28.0",
"@typescript-eslint/parser": "^2.28.0",
"babel-loader": "^8.0.6",
"cross-env": "^7.0.2",
"eslint": "^6.8.0",
"eslint-plugin-react": "^7.19.0",
"eslint-plugin-react-hooks": "^3.0.0",
Expand Down
1 change: 0 additions & 1 deletion packages/babel-plugin/src/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { transformSync, TransformOptions } from '@babel/core';
import 'jest-extended';
import compiledPlugin from '../index';

const babelOpts: TransformOptions = {
Expand Down
1 change: 0 additions & 1 deletion packages/css-in-js/src/__tests__/browser.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import { render } from '@testing-library/react';
import 'jest-extended';
import { styled } from '@compiled/css-in-js';

describe('browser', () => {
Expand Down
1 change: 0 additions & 1 deletion packages/css-in-js/src/__tests__/ssr.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*/
import React from 'react';
import { renderToStaticMarkup } from 'react-dom/server';
import 'jest-extended';
import { styled, CC } from '@compiled/css-in-js';

describe('SSR', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { render } from '@testing-library/react';
import React from 'react';
import { ClassNames } from '@compiled/css-in-js';
import '@compiled/jest-css-in-js';

describe('class names component', () => {
it('should create css from object literal', () => {
Expand Down
1 change: 0 additions & 1 deletion packages/css-in-js/src/jsx/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import '@compiled/css-in-js';
import React from 'react';
import { render } from '@testing-library/react';
import '@compiled/jest-css-in-js';

describe('css prop', () => {
it('should create css from object literal', () => {
Expand Down
1 change: 0 additions & 1 deletion packages/css-in-js/src/styled/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React from 'react';
import { render } from '@testing-library/react';
import { styled } from '@compiled/css-in-js';
import { em } from 'polished';
import '@compiled/jest-css-in-js';

describe('styled component', () => {
it('should render a simple styled div using an object', () => {
Expand Down
1 change: 0 additions & 1 deletion packages/style/src/__tests__/style-ssr.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*/
import React from 'react';
import { renderToStaticMarkup } from 'react-dom/server';
import 'jest-extended';
import Style from '../style';

describe('<Style />', () => {
Expand Down
1 change: 0 additions & 1 deletion packages/style/src/__tests__/style.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import { render } from '@testing-library/react';
import 'jest-extended';
import Style from '../style';

describe('<Style />', () => {
Expand Down
1 change: 0 additions & 1 deletion packages/ts-transform/src/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as ts from 'typescript';
import { Transformer } from 'ts-transformer-testing-library';
import 'jest-extended';
import rootTransformer from '../index';

const stubProgam: ts.Program = ({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as ts from 'typescript';
import { Transformer } from 'ts-transformer-testing-library';
import 'jest-extended';
import classNamesTransformer from '../index';

jest.mock('../../utils/hash');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as ts from 'typescript';
import { Transformer } from 'ts-transformer-testing-library';
import 'jest-extended';
import cssPropTransformer from '../index';

jest.mock('../../utils/hash');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as ts from 'typescript';
import { Transformer } from 'ts-transformer-testing-library';
import 'jest-extended';
import styledComponentTransformer from '../index';

jest.mock('../../utils/hash');
Expand Down
2 changes: 2 additions & 0 deletions test/global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import '@compiled/jest-css-in-js';
import 'jest-extended';
7 changes: 7 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3721,6 +3721,13 @@ create-react-context@^0.3.0:
gud "^1.0.0"
warning "^4.0.3"

cross-env@^7.0.2:
version "7.0.2"
resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-7.0.2.tgz#bd5ed31339a93a3418ac4f3ca9ca3403082ae5f9"
integrity sha512-KZP/bMEOJEDCkDQAyRhu3RL2ZO/SUVrxQVI0G3YEQ+OLbRA3c6zgixe8Mq8a/z7+HKlNEjo8oiLUs8iRijY2Rw==
dependencies:
cross-spawn "^7.0.1"

[email protected], cross-spawn@^6.0.0, cross-spawn@^6.0.5:
version "6.0.5"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4"
Expand Down

0 comments on commit 85c33d0

Please sign in to comment.