-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Gatsby cli repl test #22740
Gatsby cli repl test #22740
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { GatsbyCLI } from "../test-helpers" | ||
|
||
const timeout = seconds => | ||
new Promise(resolve => { | ||
setTimeout(resolve, seconds * 1000) | ||
}) | ||
|
||
const MAX_TIMEOUT = 2147483647 | ||
jest.setTimeout(MAX_TIMEOUT) | ||
|
||
describe(`gatsby repl`, () => { | ||
const cwd = `gatsby-sites/gatsby-repl` | ||
|
||
beforeAll(() => GatsbyCLI.from(cwd).invoke(`clean`)) | ||
afterAll(() => GatsbyCLI.from(cwd).invoke(`clean`)) | ||
|
||
it(`starts a gatsby site on port 8000`, async () => { | ||
// 1. Start the `gatsby develop` command | ||
const [childProcess, getLogs] = GatsbyCLI.from(cwd).invokeAsync(`repl`) | ||
|
||
// 2. Wait for the build process to finish | ||
await timeout(4) | ||
|
||
// 3. Kill the repl | ||
childProcess.kill() | ||
|
||
// 4. Make assertions | ||
const logs = getLogs() | ||
logs.should.contain(`success open and validate gatsby-configs`) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be tested? All those lines are kinda flaky and subject to change. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the point of this is to make sure the user experience is managed. So for now this is what's happening, and if it changes we should know. So I like having these tests for now. |
||
logs.should.contain(`success load plugins`) | ||
logs.should.contain(`success onPreInit`) | ||
logs.should.contain(`success initialize cache`) | ||
logs.should.contain(`success copy gatsby files`) | ||
logs.should.contain(`success onPreBootstrap`) | ||
logs.should.contain(`success createSchemaCustomization`) | ||
logs.should.contain(`success source and transform nodes`) | ||
logs.should.contain(`success building schema`) | ||
logs.should.contain(`success createPages`) | ||
logs.should.contain(`success createPagesStatefully`) | ||
logs.should.contain(`success onPreExtractQueries`) | ||
logs.should.contain(`success update schema`) | ||
logs.should.contain(`success extract queries from components`) | ||
logs.should.contain(`success write out requires`) | ||
logs.should.contain(`success write out redirect data`) | ||
logs.should.contain(`success onPostBootstrap`) | ||
logs.should.contain(`info bootstrap finished`) | ||
|
||
// This is the actual repl prompt | ||
logs.should.contain(`gatsby >`) | ||
}) | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# Typescript v1 declaration files | ||
typings/ | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# dotenv environment variable files | ||
.env* | ||
|
||
# gatsby files | ||
.cache/ | ||
public | ||
|
||
# Mac files | ||
.DS_Store | ||
|
||
# Yarn | ||
yarn-error.log | ||
.pnp/ | ||
.pnp.js | ||
# Yarn Integrity file | ||
.yarn-integrity |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"name": "gatsby-starter-default", | ||
"private": true, | ||
"description": "A simple starter to get up and developing quickly with Gatsby", | ||
"version": "0.1.0", | ||
"author": "Kyle Mathews <mathews.kyle@gmail.com>", | ||
"dependencies": { | ||
"gatsby": "^2.19.45", | ||
"prop-types": "^15.7.2", | ||
"react": "^16.12.0", | ||
"react-dom": "^16.12.0", | ||
"react-helmet": "^5.2.1" | ||
}, | ||
"devDependencies": { | ||
"prettier": "^1.19.1" | ||
}, | ||
"keywords": [ | ||
"gatsby" | ||
], | ||
"license": "MIT", | ||
"scripts": { | ||
"build": "gatsby build", | ||
"develop": "gatsby develop", | ||
"format": "prettier --write \"**/*.{js,jsx,json,md}\"", | ||
"start": "npm run develop", | ||
"serve": "gatsby serve", | ||
"clean": "gatsby clean", | ||
"test": "echo \"Write tests! -> https://gatsby.dev/unit-testing\" && exit 1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/gatsbyjs/gatsby-starter-default" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/gatsbyjs/gatsby/issues" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import React from "react" | ||
export default () => <div>Hi</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might fail because of that on slow CIs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah i realize that. I was just going to do the skateboard implementation and improve it later if it needed more stability. So far it's seemed to have worked.