From d531530c118fe720b33968b6d7d2a623e3cdcbbd Mon Sep 17 00:00:00 2001 From: jamesgeorge007 Date: Tue, 18 May 2021 14:28:47 +0530 Subject: [PATCH] test: assert for typescript template dependencies --- test/integration/create-next-app/index.test.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/test/integration/create-next-app/index.test.js b/test/integration/create-next-app/index.test.js index 3e3c8680761776..096f4fded2393d 100644 --- a/test/integration/create-next-app/index.test.js +++ b/test/integration/create-next-app/index.test.js @@ -97,9 +97,9 @@ describe('create next app', () => { const res = await run([projectName, '--typescript'], { cwd }) expect(res.exitCode).toBe(0) - expect( - fs.existsSync(path.join(cwd, projectName, 'package.json')) - ).toBeTruthy() + const pkgJSONPath = path.join(cwd, projectName, 'package.json') + + expect(fs.existsSync(pkgJSONPath)).toBeTruthy() expect( fs.existsSync(path.join(cwd, projectName, 'pages/index.tsx')) ).toBeTruthy() @@ -119,6 +119,14 @@ describe('create next app', () => { expect( fs.existsSync(path.join(cwd, projectName, '.gitignore')) ).toBeTruthy() + + // Assert for dependencies specific to the typescript template + const dependencies = ['next', 'react', 'react-dom'] + const devDependencies = ['@types/react', 'typescript'] + + const pkgJSON = require(pkgJSONPath) + expect(Object.keys(pkgJSON.dependencies)).toEqual(dependencies) + expect(Object.keys(pkgJSON.devDependencies)).toEqual(devDependencies) }) })