@@ -19,6 +19,7 @@ const expectGeneratedConfigToBeFormatted = async ({
1919 appPath ,
2020 generatedFilesThatExist ,
2121 ) ;
22+ expect ( prettierCheckResult . skipped , prettierCheckResult . output ) . toBe ( false ) ;
2223 expect ( prettierCheckResult . success , prettierCheckResult . output ) . toBe ( true ) ;
2324} ;
2425
@@ -40,6 +41,30 @@ const expectCommitlintHookToAllowMessage = async ({
4041 expect ( commitResult . success , commitResult . output ) . toBe ( true ) ;
4142} ;
4243
44+ const expectCommitlintHookToRejectMessage = async ( {
45+ env,
46+ appPath,
47+ message,
48+ } : {
49+ env : TestEnvironment ;
50+ appPath : string ;
51+ message : string ;
52+ } ) => {
53+ env . writeFile (
54+ appPath ,
55+ "commitlint-hook-test-invalid.txt" ,
56+ `commitlint hook invalid test ${ Date . now ( ) } \n` ,
57+ ) ;
58+ const commitResult = await env . commitWithMessage ( appPath , message ) ;
59+ expect ( commitResult . success , commitResult . output ) . toBe ( false ) ;
60+ expect (
61+ / s u b j e c t - e m p t y | t y p e - e m p t y | c o m m i t - m s g s c r i p t f a i l e d / i. test (
62+ commitResult . output ,
63+ ) ,
64+ commitResult . output ,
65+ ) . toBe ( true ) ;
66+ } ;
67+
4368describe ( "Next.js Integration Tests" , ( ) => {
4469 let testEnv : TestEnvironment ;
4570 const packageManager = getCurrentPackageManager ( ) ;
@@ -265,7 +290,6 @@ describe("Commitlint Integration Tests", () => {
265290 } ;
266291 packageJson . scripts = packageJson . scripts ?? { } ;
267292 packageJson . scripts . test = packageJson . scripts . test ?? "true" ;
268- ( packageJson as { type ?: string } ) . type = "module" ;
269293 env . writeFile (
270294 appPath ,
271295 "package.json" ,
@@ -277,5 +301,11 @@ describe("Commitlint Integration Tests", () => {
277301 appPath,
278302 message : "chore: test commit" ,
279303 } ) ;
304+
305+ await expectCommitlintHookToRejectMessage ( {
306+ env,
307+ appPath,
308+ message : "invalid commit message" ,
309+ } ) ;
280310 } ) ;
281311} ) ;
0 commit comments