Skip to content

tape/tap transition guide #178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
timoxley opened this issue Nov 10, 2015 · 10 comments
Closed

tape/tap transition guide #178

timoxley opened this issue Nov 10, 2015 · 10 comments

Comments

@timoxley
Copy link
Contributor

Would make migrating from tape easier if AVA & tape shared the same API.

Below is the full list of tape apis that don't exist in AVA. Most of these would only require a simple alias e.g. Test.prototype.deepEqual = Test.prototype.same

Though it's possible there's benefit in divorcing the tape API entirely & just keeping the current, simpler API. For example, not sure if it was ever a good idea to support both deepEquals and deepEqual other than to encourage bikeshedding within a team about which one to use.

const TapeTest = require('tape/lib/test')
const AVATest = require('ava/lib/test')
Object.keys(TapeTest.prototype).filter(k => !Object.keys(AVATest.prototype).includes(k))
[ 'test',
  'comment',
  'timeoutAfter',
  '_end',
  '_exit',
  '_pendingAsserts',
  'skip',
  'notok',
  'iferror',
  'ifErr',
  'strictEquals',
  'strictEqual',
  'isEqual',
  'equals',
  'equal',
  'isInequal',
  'doesNotEqual',
  'isNot',
  'isNotEqual',
  'notStrictEquals',
  'notStrictEqual',
  'notEquals',
  'notEqual',
  'isEquivalent',
  'deepEquals',
  'deepEqual',
  'looseEquals',
  'looseEqual',
  'deepLooseEqual',
  'isInequivalent',
  'isNotEquivalent',
  'isNotDeeply',
  'isNotDeepEqual',
  'notDeeply',
  'notEquivalent',
  'notDeepEqual',
  'notLooseEquals',
  'notLooseEqual',
  'notDeepLooseEqual' ]

Related to #96

@sindresorhus
Copy link
Member

I looked into this a while ago. The problem is that tape already have aliases for equal AVA methods, but with different behavior. Mainly, we have t.same which means deep strict equal, tape's t.same means deep non-strict equal. We have t.true which means val === true, while the tape version is just an alias for t.ok which is !!val.

@timoxley
Copy link
Contributor Author

@sindresorhus ahh understood, this makes sense. Can close.

@sindresorhus
Copy link
Member

I'll keep it open as I want to do a transition guide, maybe even an automated script (that would be cool!).

@sindresorhus sindresorhus changed the title tape asserts compatibility tape/tap transition guide Dec 21, 2015
@nvartolomei
Copy link

Those could be written as codemods btw https://github.com/facebook/jscodeshift

@sindresorhus
Copy link
Member

@nvartolomei Yup, that would be rad. I've been thinking about this for a while.

Opened a separate issue → #644.

@novemberborn
Copy link
Member

Also see discussion in #445.

@huan
Copy link

huan commented Aug 31, 2016

I just switched from tap/tape to ava, which benifit me reducing the test time from dozens of minutes to around 3 minutes. ava is great.

when I made the transition, the main pain to me is the following 2 changes:

  1. rename t.equal to t.is
  2. rename t.ok to t.truthy

the reason I found this issue is because I have the same idea with @timoxley . but after I saw the explains from @sindresorhus , I agree there will not easy to switch between ava and tap/tape. (not like switch between tap and tape, which is only need to change one line)

so my sugestion is: at least we alias those two methods(equal & is, ok & truthy), because they have the same behaviour, and will let developer switch more easier, without cause any confusing.

@sindresorhus
Copy link
Member

@zixia We're actually very close to having an automatic migration script: avajs/ava-codemods#28 😃

@huan
Copy link

huan commented Aug 31, 2016

@sindresorhus ah, cool. it will help much. thanks!

@sotojuan sotojuan removed their assignment Dec 20, 2016
@AutoSponge
Copy link

If we can get t.equal to alias t.is then spok just works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants