Repository: gatsbyjs/gatsby
File: packages/gatsby-source-drupal/src/__tests__/index.js (JavaScript)

Code before:
    expect(nodes[createNodeId(`file-1`)]).toBeDefined()
    expect(nodes[createNodeId(`file-2`)]).toBeDefined()
    expect(nodes[createNodeId(`tag-1`)]).toBeUndefined()
    expect(nodes[createNodeId(`tag-2`)]).toBeUndefined()
    expect(nodes[createNodeId(`article-1`)]).toBeDefined()
    expect(nodes[createNodeId(`article-2`)]).toBeDefined()
    expect(nodes[createNodeId(`article-3`)]).toBeDefined()
  })

  it(`Verify JSON:API includes relationships`, async () => {
    // Reset nodes and test includes relationships.
    Object.keys(nodes).forEach(key => delete nodes[key])
    const disallowedLinkTypes = [`self`, `describedby`, `taxonomy_term--tags`]
    const filters = {
      "node--article": `include=field_tags`,
    }
    const apiBase = `jsonapi-includes`
    await sourceNodes(args, { baseUrl, apiBase, disallowedLinkTypes, filters })
    expect(Object.keys(nodes).length).not.toEqual(0)
    expect(nodes[createNodeId(`tag-1`)]).toBeUndefined()
    expect(nodes[createNodeId(`tag-2`)]).toBeUndefined()
    expect(nodes[createNodeId(`tag-3`)]).toBeDefined()
    expect(nodes[createNodeId(`article-5`)]).toBeDefined()
  })

  describe.only(`Error handling`, () => {
    describe(`Does end activities if error is thrown`, () => {
      const axios = require(`axios`)
      beforeEach(() => {
        nodes = {}
        reporter.activityTimer.mockClear()
        activity.start.mockClear()
        activity.end.mockClear()
        axios.get.mockClear()
        downloadFileSpy.mockClear()
      })

      it(`during data fetching`, async () => {
        axios.get.mockImplementationOnce(() => {
          throw new Error(`data fetching failed`)
        })
        expect.assertions(5)

        try {
          await sourceNodes(args, { baseUrl })
        } catch (e) {
          expect(e).toMatchInlineSnapshot(`[Error: data fetching failed]`)
        }

        expect(reporter.activityTimer).toHaveBeenCalledTimes(1)
        expect(reporter.activityTimer).toHaveBeenNthCalledWith(

Review comment (suggestion):
I think this was left from testing
```suggestion
  describe(`Error handling`, () => {
```

Code after:
    expect(nodes[createNodeId(`file-1`)]).toBeDefined()
    expect(nodes[createNodeId(`file-2`)]).toBeDefined()
    expect(nodes[createNodeId(`tag-1`)]).toBeUndefined()
    expect(nodes[createNodeId(`tag-2`)]).toBeUndefined()
    expect(nodes[createNodeId(`article-1`)]).toBeDefined()
    expect(nodes[createNodeId(`article-2`)]).toBeDefined()
    expect(nodes[createNodeId(`article-3`)]).toBeDefined()
  })

  it(`Verify JSON:API includes relationships`, async () => {
    // Reset nodes and test includes relationships.
    Object.keys(nodes).forEach(key => delete nodes[key])
    const disallowedLinkTypes = [`self`, `describedby`, `taxonomy_term--tags`]
    const filters = {
      "node--article": `include=field_tags`,
    }
    const apiBase = `jsonapi-includes`
    await sourceNodes(args, { baseUrl, apiBase, disallowedLinkTypes, filters })
    expect(Object.keys(nodes).length).not.toEqual(0)
    expect(nodes[createNodeId(`tag-1`)]).toBeUndefined()
    expect(nodes[createNodeId(`tag-2`)]).toBeUndefined()
    expect(nodes[createNodeId(`tag-3`)]).toBeDefined()
    expect(nodes[createNodeId(`article-5`)]).toBeDefined()
  })

  describe(`Error handling`, () => {
    describe(`Does end activities if error is thrown`, () => {
      const axios = require(`axios`)
      beforeEach(() => {
        nodes = {}
        reporter.activityTimer.mockClear()
        activity.start.mockClear()
        activity.end.mockClear()
        axios.get.mockClear()
        downloadFileSpy.mockClear()
      })

      it(`during data fetching`, async () => {
        axios.get.mockImplementationOnce(() => {
          throw new Error(`data fetching failed`)
        })
        expect.assertions(5)

        try {
          await sourceNodes(args, { baseUrl })
        } catch (e) {
          expect(e).toMatchInlineSnapshot(`[Error: data fetching failed]`)
        }

        expect(reporter.activityTimer).toHaveBeenCalledTimes(1)
        expect(reporter.activityTimer).toHaveBeenNthCalledWith(