Skip to content

Instantly share code, notes, and snippets.

@GustavoGomesDias
Last active July 28, 2022 19:55
Show Gist options
  • Save GustavoGomesDias/a6f51ac7f09b72529d797a6bb06d323a to your computer and use it in GitHub Desktop.
Save GustavoGomesDias/a6f51ac7f09b72529d797a6bb06d323a to your computer and use it in GitHub Desktop.
vscode.snippets

TDD Describe

{
	"Jest Describe": {
		"prefix": ["desc", "jdesc"],
		"body": [
			"describe('', () => {",
			"  test('Should ', () => {});",
			"});",
			"",
		]
	}
}

TDD Test

{
	"Jest Test": {
		"prefix": ["test", "it"],
		"body": [
			"test('Should ', () => {});"
		]
	}
}

TDD With SuperTest and Express

{
	"Jest Test With SuperTest And Express": {
		"prefix": [
			"spt",
			"super"
		],
		"body": [
			"import { Server } from 'http';",
			"import request from 'supertest';",
			"import app from 'path/to/app';",
			"",
			"describe('', () => {",
			"  let server: Server;",
			"  let supertest: request.SuperAgentTest;",
			"  beforeAll(async () => {",
			"    server = app.listen(4001);",
			"    supertest = request.agent(server);",
			"  });",
			"",
			"  afterAll(async () => {",
			"    if (server) {",
			"      server.close();",
			"    }",
			"  });",
			"",
			"  test('Should ', () => {});",
			"});",
			""
		]
	}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment