import assert from 'node:assert/strict';
import test from 'node:test';

const nextConfig = require('../../next.config.js');

test('next dev ignores test compiler output to avoid route refresh interruptions', () => {
  assert.equal(typeof nextConfig.webpack, 'function');

  const config = nextConfig.webpack({ watchOptions: { ignored: ['**/node_modules/**'] } }, { dev: true });
  const ignored = config.watchOptions?.ignored;
  const ignoredList = Array.isArray(ignored) ? ignored : [ignored];

  assert.ok(ignoredList.includes('**/.tmp-test/**'));
});

test('next dev keeps watch ignored entries compatible with webpack schema', () => {
  const config = nextConfig.webpack({ watchOptions: { ignored: [/node_modules/] } }, { dev: true });
  const ignored = config.watchOptions?.ignored;
  const ignoredList = Array.isArray(ignored) ? ignored : [ignored];

  assert.deepEqual(ignoredList, ['**/.tmp-test/**']);
});
