Skip to content

Commit

Permalink
fix(vitest): split out tests (#870)
Browse files Browse the repository at this point in the history
* test: try splitting out tests

* ci: knip fix

* ci: oops

* chore: remove unused snapshots

* refactor: try using MSW instead of nock in single-threaded tests

* chore: temporarily don't worry about coverage 🤐

* chore: backfill headers-polyfill

* ci: re-enable tests on node 14

* test: add JSON error body

* ci: try matrix for threads

* ci: oops

* chore: copy edits

* chore: run build before tests

* fix(ci): split out ci and test steps

* chore: fix lockfile

* Revert "fix(ci): split out ci and test steps"

This reverts commit 112ec66.

* chore: clean out some comment junk

* chore: try fixing lockfile (again)

@esbuild/android-arm wasn't showing up in here, i think it got accidentally removed which is causing node 14 tests to break

* feat: better header checking
  • Loading branch information
kanadgupta authored Sep 5, 2023
1 parent f3dc0ac commit ed480ed
Show file tree
Hide file tree
Showing 27 changed files with 2,794 additions and 2,707 deletions.
11 changes: 3 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
fail-fast: false
matrix:
node-version:
- 14
- 16
- 18
- 20
Expand All @@ -28,14 +29,8 @@ jobs:
node-version: ${{ matrix.node-version }}
cache: npm

- name: Install deps
run: npm ci

- name: Build dist
run: npm run build

- name: Run tests
run: npm test
- name: Build and run tests
run: npm cit

lint:
runs-on: ubuntu-latest
Expand Down
2 changes: 0 additions & 2 deletions __tests__/cmds/__snapshots__/whoami.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`rdme whoami > should return the authenticated user 1`] = `"You are currently logged in as [email protected] to the subdomain project."`;

exports[`rdme whoami should return the authenticated user 1`] = `"You are currently logged in as [email protected] to the subdomain project."`;
3 changes: 0 additions & 3 deletions __tests__/cmds/docs/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ const key = 'API_KEY';
const version = '1.0.0';
const category = 'CATEGORY_ID';

const testWorkingDir = process.cwd();

describe('rdme docs', () => {
beforeAll(() => {
nock.disableNetConnect();
Expand Down Expand Up @@ -448,7 +446,6 @@ describe('rdme docs', () => {
after();

consoleInfoSpy.mockRestore();
process.chdir(testWorkingDir);
});

it('should create GHA workflow with version passed in via prompt', async () => {
Expand Down
335 changes: 0 additions & 335 deletions __tests__/cmds/openapi/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -205,47 +205,6 @@ jobs:
"
`;

exports[`rdme openapi > GHA onboarding E2E tests > should create GHA workflow (including workingDirectory) 1`] = `
"
Your GitHub Actions workflow file has been created! ✨
Almost done! Just a couple more steps:
1. Push your newly created file (.github/workflows/openapi-file-workingdirectory.yml) to GitHub 🚀
2. Create a GitHub secret called README_API_KEY and populate the value with your ReadMe API key (••••••••••••I_KEY) 🔑
🔐 Check out GitHub's docs for more info on creating encrypted secrets (https://docs.github.com/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository)
🦉 If you have any more questions, feel free to drop us a line! [email protected]
"
`;

exports[`rdme openapi > GHA onboarding E2E tests > should create GHA workflow (including workingDirectory) 2`] = `
"# This GitHub Actions workflow was auto-generated by the \`rdme\` cli on 2022-01-01T00:00:00.000Z
# You can view our full documentation here: https://docs.readme.com/docs/rdme
name: ReadMe GitHub Action 🦉
on:
push:
branches:
# This workflow will run every time you push code to the following branch: \`openapi-branch-workingdirectory\`
# Check out GitHub's docs for more info on configuring this:
# https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
- openapi-branch-workingdirectory
jobs:
rdme-openapi:
runs-on: ubuntu-latest
steps:
- name: Check out repo 📚
uses: actions/checkout@v3
- name: Run \`openapi\` command 🚀
uses: readmeio/rdme@v7
with:
rdme: openapi petstore.json --key=\${{ secrets.README_API_KEY }} --id=1 --workingDirectory=./__tests__/__fixtures__/relative-ref-oas
"
`;

exports[`rdme openapi > GHA onboarding E2E tests > should create GHA workflow (update spec via prompt) 1`] = `
"
Your GitHub Actions workflow file has been created! ✨
Expand Down Expand Up @@ -774,297 +733,3 @@ exports[`rdme openapi > upload > should update title, bundle and upload the expe
],
}
`;
exports[`rdme openapi > upload > should use specified working directory and upload the expected content 1`] = `
{
"components": {
"securitySchemes": {
"api_key": {
"in": "header",
"name": "api_key",
"type": "apiKey",
},
"petstore_auth": {
"flows": {
"implicit": {
"authorizationUrl": "http://petstore.swagger.io/oauth/dialog",
"scopes": {
"read:pets": "read your pets",
"write:pets": "modify pets in your account",
},
},
},
"type": "oauth2",
},
},
},
"info": {
"title": "Example petstore to demo our handling of relative external $ref pointers",
"version": "1.0.0",
},
"openapi": "3.0.0",
"paths": {
"/pet": {
"post": {
"description": "",
"operationId": "addPet",
"requestBody": {
"$ref": "#/paths/~1pet/put/requestBody",
},
"responses": {
"405": {
"description": "Invalid input",
},
},
"security": [
{
"petstore_auth": [
"write:pets",
"read:pets",
],
},
],
"summary": "Add a new pet to the store",
"tags": [
"pet",
],
},
"put": {
"description": "",
"operationId": "updatePet",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/paths/~1pet~1%7BpetId%7D/get/responses/200/content/application~1xml/schema",
},
},
"application/xml": {
"schema": {
"$ref": "#/paths/~1pet~1%7BpetId%7D/get/responses/200/content/application~1xml/schema",
},
},
},
"description": "Pet object that needs to be added to the store",
"required": true,
},
"responses": {
"400": {
"description": "Invalid ID supplied",
},
"404": {
"description": "Pet not found",
},
"405": {
"description": "Validation exception",
},
},
"security": [
{
"petstore_auth": [
"write:pets",
"read:pets",
],
},
],
"summary": "Update an existing pet",
"tags": [
"pet",
],
},
},
"/pet/{petId}": {
"get": {
"description": "Returns a single pet",
"operationId": "getPetById",
"parameters": [
{
"description": "ID of pet to return",
"in": "path",
"name": "petId",
"required": true,
"schema": {
"format": "int64",
"type": "integer",
},
},
],
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/paths/~1pet~1%7BpetId%7D/get/responses/200/content/application~1xml/schema",
},
},
"application/xml": {
"schema": {
"properties": {
"category": {
"properties": {
"id": {
"format": "int64",
"type": "integer",
},
"name": {
"type": "string",
},
},
"type": "object",
"xml": {
"name": "Category",
},
},
"id": {
"default": 40,
"example": 25,
"format": "int64",
"type": "integer",
},
"name": {
"example": "doggie",
"type": "string",
},
"photoUrls": {
"items": {
"example": "https://example.com/photo.png",
"type": "string",
},
"type": "array",
"xml": {
"name": "photoUrl",
"wrapped": true,
},
},
"status": {
"description": "pet status in the store",
"enum": [
"available",
"pending",
"sold",
],
"type": "string",
},
"tags": {
"items": {
"properties": {
"id": {
"format": "int64",
"type": "integer",
},
"name": {
"type": "string",
},
},
"type": "object",
"xml": {
"name": "Tag",
},
},
"type": "array",
"xml": {
"name": "tag",
"wrapped": true,
},
},
},
"required": [
"name",
"photoUrls",
],
"type": "object",
"xml": {
"name": "Pet",
},
},
},
},
"description": "successful operation",
},
"400": {
"description": "Invalid ID supplied",
},
"404": {
"description": "Pet not found",
},
"default": {
"description": "successful response",
},
},
"security": [
{
"api_key": [],
},
],
"summary": "Find pet by ID",
"tags": [
"pet",
],
},
},
"/user": {
"post": {
"description": "This can only be done by the logged in user.",
"operationId": "createUser",
"requestBody": {
"content": {
"application/json": {
"schema": {
"properties": {
"email": {
"type": "string",
},
"firstName": {
"type": "string",
},
"id": {
"format": "int64",
"type": "integer",
},
"lastName": {
"type": "string",
},
"password": {
"type": "string",
},
"phone": {
"type": "string",
},
"userStatus": {
"description": "User Status",
"format": "int32",
"type": "integer",
},
"username": {
"type": "string",
},
},
"type": "object",
"xml": {
"name": "User",
},
},
},
},
"description": "Created user object",
"required": true,
},
"responses": {
"default": {
"description": "successful operation",
},
},
"summary": "Create user",
"tags": [
"user",
],
},
},
},
"servers": [
{
"url": "http://petstore.swagger.io/v2",
},
],
}
`;
Loading

0 comments on commit ed480ed

Please sign in to comment.