···1313export const test = createTest(
1414 function (name: string | Function, fn?: TestFunction, options?: number | TestOptions) {
1515 if (getCurrentTest())
1616- throw new Error('Nested tests are not allowed')
1616+ throw new Error('Calling the test function inside another test function is not allowed. Please put it inside "describe" or "suite" so it can be properly collected.')
17171818 getCurrentSuite().test.fn.call(this, formatName(name), fn, options)
1919 },
+5-5
test/core/test/nested-test.test.ts
···33test('nested test should throw error', () => {
44 expect(() => {
55 test('test inside test', () => {})
66- }).toThrowErrorMatchingInlineSnapshot(`[Error: Nested tests are not allowed]`)
66+ }).toThrowErrorMatchingInlineSnapshot(`[Error: Calling the test function inside another test function is not allowed. Please put it inside "describe" or "suite" so it can be properly collected.]`)
7788 expect(() => {
99 test.each([1, 2, 3])('test.each inside test %d', () => {})
1010- }).toThrowErrorMatchingInlineSnapshot(`[Error: Nested tests are not allowed]`)
1010+ }).toThrowErrorMatchingInlineSnapshot(`[Error: Calling the test function inside another test function is not allowed. Please put it inside "describe" or "suite" so it can be properly collected.]`)
11111212 expect(() => {
1313 test.skipIf(false)('test.skipIf inside test', () => {})
1414- }).toThrowErrorMatchingInlineSnapshot(`[Error: Nested tests are not allowed]`)
1414+ }).toThrowErrorMatchingInlineSnapshot(`[Error: Calling the test function inside another test function is not allowed. Please put it inside "describe" or "suite" so it can be properly collected.]`)
1515})
16161717describe('parallel tests', () => {
1818 test.concurrent('parallel test 1 with nested test', () => {
1919 expect(() => {
2020 test('test inside test', () => {})
2121- }).toThrowErrorMatchingInlineSnapshot(`[Error: Nested tests are not allowed]`)
2121+ }).toThrowErrorMatchingInlineSnapshot(`[Error: Calling the test function inside another test function is not allowed. Please put it inside "describe" or "suite" so it can be properly collected.]`)
2222 })
2323 test.concurrent('parallel test 2 without nested test', () => {})
2424 test.concurrent('parallel test 3 without nested test', () => {})
2525 test.concurrent('parallel test 4 with nested test', () => {
2626 expect(() => {
2727 test('test inside test', () => {})
2828- }).toThrowErrorMatchingInlineSnapshot(`[Error: Nested tests are not allowed]`)
2828+ }).toThrowErrorMatchingInlineSnapshot(`[Error: Calling the test function inside another test function is not allowed. Please put it inside "describe" or "suite" so it can be properly collected.]`)
2929 })
3030})