diff --git a/docs/recipes/babelrc.md b/docs/recipes/babelrc.md index 2973f6fe1..ff6cd4978 100644 --- a/docs/recipes/babelrc.md +++ b/docs/recipes/babelrc.md @@ -14,18 +14,18 @@ There are multiple options for configuring how AVA transpiles your tests using B ## AVA's default transpiler behavior -By default, AVA transpiles your tests (and only your tests) using the [`es2015-node4`](https://github.com/jbach/babel-preset-es2015-node4) on Node.js 4 or [`node6`](https://github.com/salakar/babel-preset-node6) on Node.js 6 and higher, and [`stage-2`](http://babeljs.io/docs/plugins/preset-stage-2/) Babel presets. This is a great option for small modules where you do not desire a build step to transpile your source before deploying to `npm`. +By default, AVA transpiles your tests and helper files using the [`@ava/stage-4`](https://github.com/avajs/babel-preset-stage-4) Babel preset. This is a great option for small modules where you do not desire a build step to transpile your source before deploying to `npm`. ## Customizing how AVA transpiles your tests -You can override the default Babel configuration AVA uses for test transpilation in `package.json`. For example, the configuration below adds the Babel `rewire` plugin, and opts to only use the Babel [`stage-3`](http://babeljs.io/docs/plugins/preset-stage-3/) preset (which is a subset of [`stage-2`](http://babeljs.io/docs/plugins/preset-stage-2/)). +You can override the default Babel configuration AVA uses for test transpilation in `package.json`. For example, the configuration below adds the Babel `rewire` plugin, and adds the Babel [`stage-3`](http://babeljs.io/docs/plugins/preset-stage-3/) preset. ```json { "ava": { "babel": { "plugins": ["rewire"], - "presets": ["es2015-node4", "stage-3"] + "presets": ["@ava/stage-4", "stage-3"] } } } @@ -43,7 +43,7 @@ To transpile your sources, you will need to define a [`babel config` ](http://ba "require": ["babel-register"] }, "babel": { - "presets": ["es2015-node4"] + "presets": ["@ava/stage-4"] } } ``` @@ -63,12 +63,12 @@ Using the `"inherit"` shortcut will cause your tests to be transpiled the same a "babel": "inherit" }, "babel": { - "presets": ["es2015-node4", "react"] + "presets": ["@ava/stage-4", "react"] } } ``` -In the above example, both tests and sources will be transpiled using the [`es2015-node4`](https://github.com/jbach/babel-preset-es2015-node4) and [`react`](http://babeljs.io/docs/plugins/preset-react/) presets. +In the above example, both tests and sources will be transpiled using the [`@ava/stage-4`](https://github.com/avajs/babel-preset-stage-4) and [`react`](http://babeljs.io/docs/plugins/preset-react/) presets. ## Extend your source transpilation configuration @@ -87,12 +87,12 @@ When specifying the Babel config for your tests, you can set the `babelrc` optio } }, "babel": { - "presets": ["es2015-node4", "react"] + "presets": ["@ava/stage-4", "react"] } } ``` -In the above example, *sources* are compiled use [`es2015-node4`](https://github.com/jbach/babel-preset-es2015-node4) and [`react`](http://babeljs.io/docs/plugins/preset-react/), *tests* use those same plugins, plus the additional `custom` plugins specified. +In the above example, *sources* are compiled use [`@ava/stage-4`](https://github.com/avajs/babel-preset-stage-4) and [`react`](http://babeljs.io/docs/plugins/preset-react/), *tests* use those same plugins, plus the additional `custom` plugins specified. ## Extend an alternate config file. diff --git a/index.js.flow b/index.js.flow index 9675aa594..98480205e 100644 --- a/index.js.flow +++ b/index.js.flow @@ -43,10 +43,6 @@ type AssertContext = { truthy(value: mixed, message?: string): void; // Assert that value is falsy. falsy(value: mixed, message?: string): void; - // DEPRECATED, use `truthy`. Assert that value is truthy. - ok(value: mixed, message?: string): void; - // DEPRECATED, use `falsy`. Assert that value is falsy. - notOk(value: mixed, message?: string): void; // Assert that value is true. true(value: mixed, message?: string): void; // Assert that value is false. @@ -60,12 +56,6 @@ type AssertContext = { // Assert that value is not deep equal to expected. notDeepEqual(value: U, expected: U, message?: string): void; // Assert that function throws an error or promise rejects. - // DEPRECATED, use `deepEqual`. Assert that value is deep equal to expected. - // @param error Can be a constructor, regex, error message or validation function. - same(value: U, expected: U, message?: string): void; - // DEPRECATED use `notDeepEqual`. Assert that value is not deep equal to expected. - notSame(value: U, expected: U, message?: string): void; - // Assert that function throws an error or promise rejects. // @param error Can be a constructor, regex, error message or validation function. throws(value: PromiseLike, error?: ErrorValidator, message?: string): Promise; throws(value: () => void, error?: ErrorValidator, message?: string): mixed; diff --git a/lib/assert.js b/lib/assert.js index 6e6804e98..70cc9f147 100644 --- a/lib/assert.js +++ b/lib/assert.js @@ -1,5 +1,4 @@ 'use strict'; -const util = require('util'); const assert = require('core-assert'); const deepEqual = require('lodash.isequal'); const observableToPromise = require('observable-to-promise'); @@ -184,16 +183,3 @@ x._snapshot = function (tree, optionalMessage, match, snapshotStateGetter) { x.snapshot = function (tree, optionalMessage) { x._snapshot.call(this, tree, optionalMessage); }; - -/* - * Deprecated APIs - */ -x.ok = util.deprecate(x.truthy, getDeprecationNotice('ok()', 'truthy()')); -x.notOk = util.deprecate(x.falsy, getDeprecationNotice('notOk()', 'falsy()')); -x.same = util.deprecate(x.deepEqual, getDeprecationNotice('same()', 'deepEqual()')); -x.notSame = util.deprecate(x.notDeepEqual, getDeprecationNotice('notSame()', 'notDeepEqual()')); -x.error = util.deprecate(x.ifError, getDeprecationNotice('error()', 'ifError()')); - -function getDeprecationNotice(oldApi, newApi) { - return `DEPRECATION NOTICE: ${oldApi} has been renamed to ${newApi} and will eventually be removed. See https://github.com/avajs/ava-codemods to help upgrade your codebase automatically.`; -} diff --git a/lib/babel-config.js b/lib/babel-config.js index 3cf6ebc1f..3ef31a9e1 100644 --- a/lib/babel-config.js +++ b/lib/babel-config.js @@ -3,7 +3,6 @@ const path = require('path'); const chalk = require('chalk'); const figures = require('figures'); const convertSourceMap = require('convert-source-map'); -const semver = require('semver'); const colors = require('./colors'); function validate(conf) { @@ -25,68 +24,26 @@ function validate(conf) { return conf; } -function lazy(initFn) { - let initialized = false; - let value; +function lazy(buildPreset) { + let preset; - return () => { - if (!initialized) { - initialized = true; - value = initFn(); + return babel => { + if (!preset) { + preset = buildPreset(babel); } - return value; + return preset; }; } -const defaultPresets = lazy(() => { - const esPreset = semver.satisfies(process.version, '>=6') ? - 'babel-preset-node6' : - 'babel-preset-es2015-node4'; +const stage4 = lazy(() => require('@ava/babel-preset-stage-4')()); - return [ - require('babel-preset-stage-2'), - require(esPreset) // eslint-disable-line import/no-dynamic-require - ]; -}); - -const rewritePlugin = lazy(() => { - const wrapListener = require('babel-plugin-detective/wrap-listener'); - - return wrapListener(rewriteBabelRuntimePaths, 'rewrite-runtime', { - generated: true, - require: true, - import: true +function makeTransformTestFiles(powerAssert) { + return lazy(babel => { + return require('@ava/babel-preset-transform-test-files')(babel, {powerAssert}); }); -}); - -function rewriteBabelRuntimePaths(path) { - const isBabelPath = /^babel-runtime[\\/]?/.test(path.node.value); - - if (path.isLiteral() && isBabelPath) { - path.node.value = require.resolve(path.node.value); - } } -const espowerPlugin = lazy(() => { - const babel = require('babel-core'); - const createEspowerPlugin = require('babel-plugin-espower/create'); - - // Initialize power-assert - return createEspowerPlugin(babel, { - embedAst: true, - patterns: require('./enhance-assert').PATTERNS - }); -}); - -const defaultPlugins = lazy(() => { - return [ - require('babel-plugin-ava-throws-helper'), - rewritePlugin(), - require('babel-plugin-transform-runtime') - ]; -}); - function build(babelConfig, powerAssert, filePath, code) { babelConfig = validate(babelConfig); @@ -95,7 +52,7 @@ function build(babelConfig, powerAssert, filePath, code) { if (babelConfig === 'default') { options = { babelrc: false, - presets: defaultPresets() + presets: [stage4] }; } else if (babelConfig === 'inherit') { options = { @@ -118,9 +75,10 @@ function build(babelConfig, powerAssert, filePath, code) { ast: false }); - options.plugins = (options.plugins || []) - .concat(powerAssert ? espowerPlugin() : []) - .concat(defaultPlugins()); + if (!options.presets) { + options.presets = []; + } + options.presets.push(makeTransformTestFiles(powerAssert)); return options; } @@ -143,8 +101,8 @@ function getSourceMap(filePath, code) { module.exports = { validate, build, - pluginPackages: [ - require.resolve('babel-core/package.json'), - require.resolve('babel-plugin-espower/package.json') + presetHashes: [ + require('@ava/babel-preset-stage-4/package-hash'), + require('@ava/babel-preset-transform-test-files/package-hash') ] }; diff --git a/lib/caching-precompiler.js b/lib/caching-precompiler.js index a81c0eea1..796377f81 100644 --- a/lib/caching-precompiler.js +++ b/lib/caching-precompiler.js @@ -53,13 +53,15 @@ class CachingPrecompiler { return `${result.code}\n${comment}`; } _createTransform() { - const pluginPackages = babelConfigHelper.pluginPackages; - const avaPackage = require.resolve('../package.json'); - const packages = [avaPackage].concat(pluginPackages); - const majorNodeVersion = process.version.split('.')[0]; - const babelConfig = JSON.stringify(this.babelConfig); - const packageSalt = babelConfig + majorNodeVersion + this.powerAssert; - const salt = packageHash.sync(packages, packageSalt); + const salt = packageHash.sync([ + require.resolve('../package.json'), + require.resolve('babel-core/package.json') + ], { + babelConfig: this.babelConfig, + majorNodeVersion: process.version.split('.')[0], + powerAssert: this.powerAssert, + presetHashes: babelConfigHelper.presetHashes + }); return cachingTransform({ factory: this._init, diff --git a/lib/enhance-assert.js b/lib/enhance-assert.js index 70fa8b95c..f88d530c8 100644 --- a/lib/enhance-assert.js +++ b/lib/enhance-assert.js @@ -3,6 +3,9 @@ module.exports = enhanceAssert; module.exports.formatter = formatter; +// When adding patterns, don't forget to add to +// https://github.com/avajs/babel-preset-transform-test-files/blob/master/espower-patterns.json +// Then release a new version of that preset and bump the SemVer range here. module.exports.PATTERNS = [ 't.truthy(value, [message])', 't.falsy(value, [message])', @@ -13,12 +16,7 @@ module.exports.PATTERNS = [ 't.deepEqual(value, expected, [message])', 't.notDeepEqual(value, expected, [message])', 't.regex(contents, regex, [message])', - 't.notRegex(contents, regex, [message])', - // Deprecated apis - 't.ok(value, [message])', - 't.notOk(value, [message])', - 't.same(value, expected, [message])', - 't.notSame(value, expected, [message])' + 't.notRegex(contents, regex, [message])' ]; module.exports.NON_ENHANCED_PATTERNS = [ diff --git a/package.json b/package.json index 4dbc2cbaf..0bcd8641d 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "test-win": "tap --no-cov --reporter=classic --timeout=150 test/*.js test/reporters/*.js", "visual": "node test/visual/run-visual-tests.js", "prepublish": "npm run make-ts", - "make-ts": "babel-node --presets=babel-preset-es2015-node4 --plugins=transform-runtime types/make.js" + "make-ts": "node types/make.js" }, "files": [ "lib", @@ -87,6 +87,8 @@ "observables" ], "dependencies": { + "@ava/babel-preset-stage-4": "^1.0.0", + "@ava/babel-preset-transform-test-files": "^1.0.0", "arr-flatten": "^1.0.1", "array-union": "^1.0.1", "array-uniq": "^1.0.2", @@ -95,14 +97,6 @@ "ava-init": "^0.2.0", "babel-code-frame": "^6.16.0", "babel-core": "^6.17.0", - "babel-plugin-ava-throws-helper": "^0.1.0", - "babel-plugin-detective": "^2.0.0", - "babel-plugin-espower": "^2.3.1", - "babel-plugin-transform-runtime": "^6.15.0", - "babel-preset-es2015-node4": "^2.1.0", - "babel-preset-node6": "^11.0.0", - "babel-preset-stage-2": "^6.17.0", - "babel-runtime": "^6.11.6", "bluebird": "^3.0.0", "caching-transform": "^1.0.0", "chalk": "^1.0.0", @@ -147,7 +141,7 @@ "multimatch": "^2.1.0", "observable-to-promise": "^0.4.0", "option-chain": "^0.1.0", - "package-hash": "^1.1.0", + "package-hash": "^1.2.0", "pkg-conf": "^2.0.0", "plur": "^2.0.0", "power-assert-context-formatter": "^1.0.4", @@ -157,7 +151,6 @@ "repeating": "^2.0.0", "require-precompiled": "^0.1.0", "resolve-cwd": "^1.0.0", - "semver": "^5.3.0", "slash": "^1.0.0", "source-map-support": "^0.4.0", "stack-utils": "^0.4.0", @@ -168,7 +161,6 @@ "update-notifier": "^1.0.0" }, "devDependencies": { - "babel-cli": "^6.10.1", "babel-preset-react": "^6.5.0", "cli-table2": "^0.2.0", "coveralls": "^2.11.4", diff --git a/readme.md b/readme.md index 060175768..7c4b69daa 100644 --- a/readme.md +++ b/readme.md @@ -40,7 +40,7 @@ Translations: [EspaƱol](https://github.com/avajs/ava-docs/blob/master/es_ES/rea - Enforces writing atomic tests - No implicit globals - [Isolated environment for each test file](#process-isolation) -- [Write your tests in ES2015](#es2015-support) +- [Write your tests in ES2017](#es2017-support) - [Promise support](#promise-support) - [Generator function support](#generator-function-support) - [Async function support](#async-function-support) @@ -266,7 +266,7 @@ All of the CLI options can be configured in the `ava` section of your `package.j Arguments passed to the CLI will always take precedence over the configuration in `package.json`. -See the [ES2015 support](#es2015-support) section for details on the `babel` option. +See the [ES2017 support](#es2017-support) section for details on the `babel` option. ## Documentation @@ -671,21 +671,17 @@ test(t => { }); ``` -### ES2015 support +### ES2017 support -AVA comes with built-in support for ES2015 through [Babel 6](https://babeljs.io). Just write your tests in ES2015. No extra setup needed. You can use any Babel version in your project. We use our own bundled Babel with the [`es2015`](https://babeljs.io/docs/plugins/preset-es2015/) and [`stage-2`](https://babeljs.io/docs/plugins/preset-stage-2/) presets, as well as the [`espower`](https://github.com/power-assert-js/babel-plugin-espower) and [`transform-runtime`](https://babeljs.io/docs/plugins/transform-runtime/) plugins. +AVA comes with built-in support for ES2017 through [Babel 6](https://babeljs.io). Just write your tests in ES2017. No extra setup needed. You can use any Babel version in your project. We use our own bundled Babel with our [`@ava/stage-4`](https://github.com/avajs/babel-preset-stage-4) and [`stage-2`](https://babeljs.io/docs/plugins/preset-stage-2/) preset, as well as [custom transforms](https://github.com/avajs/babel-preset-transform-test-files) for test and helper files. The corresponding Babel config for AVA's setup is as follows: ```json { "presets": [ - "es2015", - "stage-2" - ], - "plugins": [ - "espower", - "transform-runtime" + "@ava/stage-4", + "@ava/transform-test-files" ] } ``` diff --git a/test/api.js b/test/api.js index 6a18681de..a96768361 100644 --- a/test/api.js +++ b/test/api.js @@ -693,11 +693,11 @@ function generateTests(prefix, apiCreator) { }); test(`${prefix} power-assert support`, t => { - t.plan(4); + t.plan(3); const api = apiCreator({ babelConfig: { - presets: ['react', 'es2015-node4', 'stage-2'] + presets: ['react', '@ava/stage-4'] } }); @@ -715,11 +715,6 @@ function generateTests(prefix, apiCreator) { t.match( result.errors[2].error.message, - /t\.true\(o === \{ ...o \}\)\s*\n\s+\|\s*\n\s+Object\{\}/m - ); - - t.match( - result.errors[3].error.message, /t\.true\(
=== \)/m ); }); @@ -878,7 +873,7 @@ function generateTests(prefix, apiCreator) { const api = apiCreator({ babelConfig: { - presets: ['es2015-node4', 'stage-2'], + presets: ['@ava/stage-4'], plugins: [testCapitalizerPlugin] }, cacheEnabled: false diff --git a/test/babel-config.js b/test/babel-config.js index db54a053f..ad2177ab3 100644 --- a/test/babel-config.js +++ b/test/babel-config.js @@ -4,38 +4,60 @@ const path = require('path'); const test = require('tap').test; const sinon = require('sinon'); const proxyquire = require('proxyquire').noCallThru(); -const throwsHelper = require('babel-plugin-ava-throws-helper'); -const transformRuntime = require('babel-plugin-transform-runtime'); const fixture = name => path.join(__dirname, 'fixture', name); function setUp() { const customPlugin = sinon.stub().returns({visitor: {}}); - const powerAssert = sinon.stub().returns({visitor: {}}); - const rewrite = sinon.stub().returns({visitor: {}}); - const createEspowerPlugin = () => powerAssert; - const babelDetectiveWrap = () => rewrite; + const stage4 = sinon.stub().returns({plugins: []}); + const transformTestfiles = sinon.stub().returns({plugins: []}); return { customPlugin, - powerAssert, - rewrite, - createEspowerPlugin, - babelDetectiveWrap + stage4, + transformTestfiles }; } +test('uses stage-4 preset when babelConfig is "default"', t => { + const setup = setUp(); + + const babelConfigHelper = proxyquire('../lib/babel-config', { + '@ava/babel-preset-stage-4': setup.stage4, + '@ava/babel-preset-transform-test-files': setup.transformTestfiles + }); + + const babelConfig = 'default'; + + const fixturePath = fixture('es2015.js'); + const fixtureSource = fs.readFileSync(fixturePath, 'utf8'); + + const powerAssert = true; + const options = babelConfigHelper.build(babelConfig, powerAssert, fixturePath, fixtureSource); + + t.true('filename' in options); + t.true(options.sourceMaps); + t.false(options.ast); + t.true('inputSourceMap' in options); + t.false(options.babelrc); + const babel = {}; + t.strictEqual(options.presets[0](babel), setup.stage4()); + options.presets[1](babel); + t.strictDeepEqual(setup.transformTestfiles.args[0], [babel, {powerAssert}]); + t.end(); +}); + test('uses babelConfig for babel options when babelConfig is an object', t => { const setup = setUp(); const customPlugin = setup.customPlugin; const babelConfigHelper = proxyquire('../lib/babel-config', { - 'babel-plugin-espower/create': setup.createEspowerPlugin, - 'babel-plugin-detective/wrap-listener': setup.babelDetectiveWrap + '@ava/babel-preset-stage-4': setup.stage4, + '@ava/babel-preset-transform-test-files': setup.transformTestfiles }); const babelConfig = { - presets: ['stage-2', 'es2015-node4'], + presets: ['stage-2'], plugins: [customPlugin] }; @@ -50,8 +72,11 @@ test('uses babelConfig for babel options when babelConfig is an object', t => { t.false(options.ast); t.true('inputSourceMap' in options); t.false(options.babelrc); - t.strictDeepEqual(options.presets, ['stage-2', 'es2015-node4']); - t.strictDeepEqual(options.plugins, [customPlugin, setup.powerAssert, throwsHelper, setup.rewrite, transformRuntime]); + t.strictDeepEqual(options.presets.slice(0, 1), ['stage-2']); + const babel = {}; + options.presets[1](babel); + t.strictDeepEqual(setup.transformTestfiles.args[0], [babel, {powerAssert}]); + t.strictDeepEqual(options.plugins, [customPlugin]); t.end(); }); @@ -60,12 +85,12 @@ test('should reuse existing source maps', t => { const customPlugin = setup.customPlugin; const babelConfigHelper = proxyquire('../lib/babel-config', { - 'babel-plugin-espower/create': setup.createEspowerPlugin, - 'babel-plugin-detective/wrap-listener': setup.babelDetectiveWrap + '@ava/babel-preset-stage-4': setup.stage4, + '@ava/babel-preset-transform-test-files': setup.transformTestfiles }); const babelConfig = { - presets: ['stage-2', 'es2015-node4'], + presets: ['stage-2'], plugins: [customPlugin] }; @@ -79,8 +104,11 @@ test('should reuse existing source maps', t => { t.true(options.sourceMaps); t.false(options.ast); t.true('inputSourceMap' in options); - t.strictDeepEqual(options.presets, ['stage-2', 'es2015-node4']); - t.strictDeepEqual(options.plugins, [customPlugin, setup.powerAssert, throwsHelper, setup.rewrite, transformRuntime]); + t.strictDeepEqual(options.presets.slice(0, 1), ['stage-2']); + const babel = {}; + options.presets[1](babel); + t.strictDeepEqual(setup.transformTestfiles.args[0], [babel, {powerAssert}]); + t.strictDeepEqual(options.plugins, [customPlugin]); t.end(); }); @@ -89,12 +117,12 @@ test('should disable power-assert when powerAssert is false', t => { const customPlugin = setup.customPlugin; const babelConfigHelper = proxyquire('../lib/babel-config', { - 'babel-plugin-espower/create': setup.createEspowerPlugin, - 'babel-plugin-detective/wrap-listener': setup.babelDetectiveWrap + '@ava/babel-preset-stage-4': setup.stage4, + '@ava/babel-preset-transform-test-files': setup.transformTestfiles }); const babelConfig = { - presets: ['stage-2', 'es2015-node4'], + presets: ['stage-2'], plugins: [customPlugin] }; @@ -104,6 +132,9 @@ test('should disable power-assert when powerAssert is false', t => { const powerAssert = false; const options = babelConfigHelper.build(babelConfig, powerAssert, fixturePath, fixtureSource); - t.strictDeepEqual(options.plugins, [customPlugin, throwsHelper, setup.rewrite, transformRuntime]); + t.strictDeepEqual(options.presets.slice(0, 1), ['stage-2']); + const babel = {}; + options.presets[1](babel); + t.strictDeepEqual(setup.transformTestfiles.args[0], [babel, {powerAssert}]); t.end(); }); diff --git a/test/caching-precompiler.js b/test/caching-precompiler.js index 71aac2c60..ce8cd7fd1 100644 --- a/test/caching-precompiler.js +++ b/test/caching-precompiler.js @@ -83,7 +83,6 @@ test('uses default babel options when babelConfig === "default"', t => { t.true('inputSourceMap' in options); t.false(options.babelrc); t.true(Array.isArray(options.presets)); - t.true(Array.isArray(options.plugins)); t.end(); }); diff --git a/test/fixture/babelrc/.alt-babelrc b/test/fixture/babelrc/.alt-babelrc index cc5c5f72f..53013ef80 100644 --- a/test/fixture/babelrc/.alt-babelrc +++ b/test/fixture/babelrc/.alt-babelrc @@ -1,4 +1,4 @@ { - "presets": ["es2015-node4", "stage-2"], + "presets": ["@ava/stage-4"], "plugins": ["../babel-plugin-foo-to-bar"] } diff --git a/test/fixture/babelrc/.babelrc b/test/fixture/babelrc/.babelrc index 0e88723b6..2c73538a1 100644 --- a/test/fixture/babelrc/.babelrc +++ b/test/fixture/babelrc/.babelrc @@ -1,4 +1,4 @@ { - "presets": ["es2015-node4", "stage-2"], + "presets": ["@ava/stage-4"], "plugins": ["../babel-plugin-test-doubler"] } diff --git a/test/fixture/power-assert.js b/test/fixture/power-assert.js index f30554a62..a78adbf83 100644 --- a/test/fixture/power-assert.js +++ b/test/fixture/power-assert.js @@ -10,11 +10,6 @@ test.serial(t => { t.true(a === 'foo', 'with message'); }); -test.serial(t => { - const o = {}; - t.true(o === {...o}); -}); - test.serial(t => { const React = { createElement: type => type diff --git a/types/base.d.ts b/types/base.d.ts index d50e36403..78884fbaf 100644 --- a/types/base.d.ts +++ b/types/base.d.ts @@ -32,14 +32,6 @@ export interface AssertContext { * Assert that value is falsy. */ falsy(value: any, message?: string): void; - /** - * DEPRECATED, use `truthy`. Assert that value is truthy. - */ - ok(value: any, message?: string): void; - /** - * DEPRECATED, use `falsy`. Assert that value is falsy. - */ - notOk(value: any, message?: string): void; /** * Assert that value is true. */ @@ -64,16 +56,6 @@ export interface AssertContext { * Assert that value is not deep equal to expected. */ notDeepEqual(value: U, expected: U, message?: string): void; - /** - * Assert that function throws an error or promise rejects. - * DEPRECATED, use `deepEqual`. Assert that value is deep equal to expected. - * @param error Can be a constructor, regex, error message or validation function. - */ - same(value: U, expected: U, message?: string): void; - /** - * DEPRECATED use `notDeepEqual`. Assert that value is not deep equal to expected. - */ - notSame(value: U, expected: U, message?: string): void; /** * Assert that function throws an error or promise rejects. * @param error Can be a constructor, regex, error message or validation function. diff --git a/types/make.js b/types/make.js index 1b9bd0eeb..e41291d94 100644 --- a/types/make.js +++ b/types/make.js @@ -16,7 +16,7 @@ const path = require('path'); const fs = require('fs'); const runner = require('../lib/runner'); -const arrayHas = parts => part => parts.includes(part); +const arrayHas = parts => part => parts.indexOf(part) > -1; const base = fs.readFileSync(path.join(__dirname, 'base.d.ts'), 'utf8'); @@ -35,7 +35,7 @@ function generatePrefixed(prefix) { for (const part of allParts) { const parts = prefix.concat([part]); - if (prefix.includes(part) || !verify(parts, true)) { + if (prefix.indexOf(part) > -1 || !verify(parts, true)) { // Function already in prefix or not allowed here continue; } @@ -55,7 +55,7 @@ function generatePrefixed(prefix) { // `always` is a valid prefix, for instance of `always.after`, // but not a valid function name. if (verify(parts, false)) { - if (prefix.includes(parts, 'todo')) { + if (parts.indexOf('todo') > -1) { output += '\t' + writeFunction(part, 'name: string', 'void'); } else { const type = testType(parts); @@ -139,7 +139,7 @@ function exists(parts) { // Valid prefix, check whether it has members for (const prefix of allParts) { - if (!parts.includes(prefix) && exists(parts.concat([prefix]))) { + if (parts.indexOf(prefix) === -1 && exists(parts.concat([prefix]))) { return true; } }