Skip to content

Commit

Permalink
chore(tests): setup circleci to run unit tests againt v5 (#36714)
Browse files Browse the repository at this point in the history
  • Loading branch information
pieh committed Oct 3, 2022
1 parent 569b5dc commit ba146fd
Show file tree
Hide file tree
Showing 15 changed files with 3,801 additions and 2,293 deletions.
41 changes: 41 additions & 0 deletions .circleci/config.yml
Expand Up @@ -8,10 +8,14 @@ executors:
image:
type: string
default: "14.15.0"
gatsby_major:
type: string
default: "4"
docker:
- image: cimg/node:<< parameters.image >>
environment:
GATSBY_CPU_COUNT: 2
COMPILER_OPTIONS: GATSBY_MAJOR=<< parameters.gatsby_major >>

aliases:
e2e-executor-env: &e2e-executor-env
Expand Down Expand Up @@ -197,6 +201,28 @@ jobs:
- "packages/"
- "node_modules/"

bootstrap_v5:
executor:
name: node
gatsby_major: "5"
steps:
- checkout
- run: ./scripts/assert-changed-files.sh "packages/*|(e2e|integration)-tests/*|.circleci/*|scripts/e2e-test.sh|yarn.lock"
# python 2 is not built in and node-gyp needs it to build lmdb
- run: sudo apt-get update && sudo apt-get install python -y
- <<: *restore_cache
- <<: *install_node_modules
- <<: *check_lockfile
- <<: *validate_renovate
- <<: *persist_cache
- run: yarn bootstrap -- concurrency=2
# Persist the workspace again with all packages already built
- persist_to_workspace:
root: ./
paths:
- "packages/"
- "node_modules/"

lint:
executor: node
steps:
Expand Down Expand Up @@ -240,6 +266,13 @@ jobs:
image: "18.2.0"
<<: *test_template

unit_tests_node18_v5:
executor:
name: node
image: "18.2.0"
gatsby_major: "5"
<<: *test_template

integration_tests_gatsby_source_wordpress:
machine:
image: "ubuntu-2004:202107-02"
Expand Down Expand Up @@ -668,3 +701,11 @@ workflows:
branches:
only:
- master

build-test_v5:
jobs:
- bootstrap_v5
- unit_tests_node18_v5:
<<: *ignore_docs
requires:
- bootstrap_v5
Expand Up @@ -25,6 +25,8 @@ function transform(query, filename) {
return code
}

const itWhenV4 = _CFLAGS_.GATSBY_MAJOR !== `5` ? it : it.skip

describe(`babel-plugin-remove-graphql-queries`, () => {
it.todo(
`Works correctly with the kitchen sink`
Expand Down Expand Up @@ -221,7 +223,7 @@ describe(`babel-plugin-remove-graphql-queries`, () => {
`)
})

it(`Transforms queries in <StaticQuery>`, () => {
itWhenV4(`Transforms queries in <StaticQuery>`, () => {
matchesSnapshot(`
import * as React from 'react'
import { graphql, StaticQuery } from 'gatsby'
Expand All @@ -235,8 +237,10 @@ describe(`babel-plugin-remove-graphql-queries`, () => {
`)
})

it(`Transforms queries defined in own variable in <StaticQuery>`, () => {
matchesSnapshot(`
itWhenV4(
`Transforms queries defined in own variable in <StaticQuery>`,
() => {
matchesSnapshot(`
import * as React from 'react'
import { graphql, StaticQuery } from 'gatsby'
Expand All @@ -249,9 +253,10 @@ describe(`babel-plugin-remove-graphql-queries`, () => {
/>
)
`)
})
}
)

it(`transforms exported variable queries in <StaticQuery>`, () => {
itWhenV4(`transforms exported variable queries in <StaticQuery>`, () => {
matchesSnapshot(`
import * as React from 'react'
import { graphql, StaticQuery } from 'gatsby'
Expand Down Expand Up @@ -430,7 +435,7 @@ describe(`babel-plugin-remove-graphql-queries`, () => {
)
})

it(`Handles closing StaticQuery tag`, () => {
itWhenV4(`Handles closing StaticQuery tag`, () => {
matchesSnapshot(`
import * as React from 'react'
import { graphql, StaticQuery } from 'gatsby'
Expand All @@ -445,7 +450,7 @@ describe(`babel-plugin-remove-graphql-queries`, () => {
`)
})

it(`Doesn't add data import for non static queries`, () => {
itWhenV4(`Doesn't add data import for non static queries`, () => {
matchesSnapshot(`
import * as React from 'react'
import { StaticQuery, graphql } from "gatsby"
Expand Down
Expand Up @@ -77,50 +77,6 @@ Array [
]
`;

exports[`babel-preset-gatsby-package in browser mode specifies the proper plugins 1`] = `
Array [
"@babel/plugin-proposal-nullish-coalescing-operator",
"@babel/plugin-proposal-optional-chaining",
"@babel/plugin-transform-runtime",
"@babel/plugin-syntax-dynamic-import",
"babel-plugin-dynamic-import-node",
Array [
"./babel-transform-compiler-flags",
Object {
"availableFlags": Array [
"GATSBY_MAJOR",
],
"flags": Object {
"GATSBY_MAJOR": "4",
},
},
],
"babel-plugin-lodash",
]
`;

exports[`babel-preset-gatsby-package in node mode can enable compilerFlags 1`] = `
Array [
"@babel/plugin-proposal-nullish-coalescing-operator",
"@babel/plugin-proposal-optional-chaining",
"@babel/plugin-transform-runtime",
"@babel/plugin-syntax-dynamic-import",
"babel-plugin-dynamic-import-node",
Array [
"./babel-transform-compiler-flags",
Object {
"availableFlags": Array [
"MAJOR",
],
"flags": Object {
"GATSBY_MAJOR": "4",
},
},
],
"babel-plugin-lodash",
]
`;

exports[`babel-preset-gatsby-package in node mode specifies proper presets 1`] = `
Array [
Array [
Expand Down Expand Up @@ -168,25 +124,3 @@ Array [
"@babel/preset-flow",
]
`;

exports[`babel-preset-gatsby-package in node mode specifies the proper plugins 1`] = `
Array [
"@babel/plugin-proposal-nullish-coalescing-operator",
"@babel/plugin-proposal-optional-chaining",
"@babel/plugin-transform-runtime",
"@babel/plugin-syntax-dynamic-import",
"babel-plugin-dynamic-import-node",
Array [
"./babel-transform-compiler-flags",
Object {
"availableFlags": Array [
"GATSBY_MAJOR",
],
"flags": Object {
"GATSBY_MAJOR": "4",
},
},
],
"babel-plugin-lodash",
]
`;

0 comments on commit ba146fd

Please sign in to comment.