3 Minutes with Kent

3 Minutes with Kent

By Kent C. DoddsTechnology
Download on the App Store

All 3 Minutes with Kent episodes

  • AMA: TypeScript or Babel?

    I got a question on my

    AMA asking me about whether I prefer TypeScript or Babel. I prefer
    Babel because it has better interop and a wider community. For more, listen
    to this 3 minute podcast :)

    See you all on twitter!

    3 min
  • Change the pace of your day-to-day

    I've recently been working on prettier-eslint and an accomanying cli and it's been a lot of

    fun. I really think that doing this kind of thing can really change the
    pace of your day-to-day and encourage you to do the same!

    See you all on twitter!

    3 min
  • Q&A: Deploying and Build Process

    David asked me about my

    Deploy/Build process and it was easier to answer in audio form :)

    Links: What we can learn about testing from the wheel

    (my talk at Ignite Fluent 2016)

    See you all on twitter!

    3 min
  • Testing and Transpilation

    I got a question

    about why we test our pre-transpiled code (or rather, instrument that code
    for coverage) rather than our post-transpiled code. So here's my answer. I
    reference babel-plugin-__coverage__ (use this with
    karma) and nyc (use this with tests
    run in node, like with mocha or
    ava).

    Good luck!

    3 min
  • Q&A: Aphrodite vs. Radium

    Alex Booker asks:

    Hi, Kent

    I've seen you advocating Aphrodite on Twitter and noticed you're using it

    for the JavaScript Air site

    Just wondering what drew you to Aphrodite over it's competitors (most

    notably Radium)

    I have a small amount of exposure to both and they seem to accomplish

    same thing but Radium is more mature

    Thanks

    P.S. I hope you're having a nice trip, mate ๐Ÿ˜€

    Also, you might be interested in this CSS in JS comparison. (Note this PR)

    I hope this answer helps!

    3 min
  • Nested Unit Tests: An Anti-Pattern

    At first I was really bothered that AVA didn't have support for nested tests, but now I consider nesting tests to be an anti-pattern.

    Here's an example of the kind of thing I mean (see this in a syntax-highlighted gist here):

    Mocha with nesting (don't mind the actual tests, just imagine what this would be like with a larger test file):

    import Customers from './Customers'
    import getMockCustomers from './Customers/mocks'
    describe('Customers', () => {
    let mockCustomers
    beforeEach(() => {
    Customers.setCustomers([]) // initialize to empty for most tests
    mockCustomers = getMockCustomers() // have mock customers available
    })
    afterEach(() => {
    Customers.setCustomers([]) // clean up just in case
    })
    describe('getCustomers', () => {
    beforeEach(() => {
    Customers.setCustomers(mockCustomers)
    })
    it('should return the existing customers', () => {
    const customers = Customers.getCustomers()
    expect(customers).to.be.eql(mockCustomers)
    // questions you must ask if you're not familiar with this file and
    it's bigger:
    // - where does `mockCustomers` come from?
    // - what make `getCustomers` return the mockCustomers?
    })
    })
    describe('setCustomers', () => {
    it('should set the customers array', () => {
    Customers.setCustomers(mockCustomers)
    const customers = Customers.getCustomers()
    expect(customers).to.be.eql(mockCustomers)
    // question you must ask if you're not familiar with this file and
    it's bigger:
    // - where does `mockCustomers` come from? What is it initialized as?
    })
    })
    })

    Here's what it would look like without nesting (with AVA, though you could

    mostly do this with Mocha too):

    import test from 'ava'
    test('getCustomers: should return the existing customers', t => {
    const mockCustomers = initializeCustomers()
    const customers = Customers.getCustomers()
    t.deepEqual(customers, mockCustomers)
    cleanupCustomers()
    })
    test('setCustomers: should set the customers array', t => {
    initializeCustomers([])
    const mockCustomers = getMockCustomers()
    Customers.setCustomers(mockCustomers)
    const customers = Customers.getCustomers()
    t.deepEqual(customers, mockCustomers)
    cleanupCustomers()
    })
    function initializeCustomers(initialCustomers = getMockCustomers()) {
    Customers.setCustomers(initialCustomers)
    return initialCustomers
    }
    function cleanupCustomers() {
    Customers.setCustomers([])
    }

    Like I said, this may be a bad example. Don't be distracted by the tests

    themselves. Just look at the it blocks above in the Mocha tests and
    compare it to the test block in the AVA tests below. The difference is
    that with the it blocks, you have to keep in your head what's going on in
    a beforeEach and that relationship is implicit. In the test block,
    there is a level of abstraction, but it's explicit so you don't need to
    worry about keeping it in your head because it's in front of your face.

    I hope this is helpful!

    3 min
  • OSS Licenses

    Check out the Open Source Definition. A

    license is required for your project to be considered Open Source. I
    recommend you choose a license.

    3 min