Repository: parcel-bundler/parcel
File: packages/core/integration-tests/test/elm.js (JavaScript)

Code before:
    await run(b);
    let js = await outputFS.readFile(path.join(distDir, 'index.js'), 'utf8');
    assert(!js.includes('elm$browser$Debugger'));
  });

  it('should minify Elm in production mode', async function () {
    let b = await bundle(path.join(__dirname, '/integration/elm/index.js'), {
      mode: 'production',
      defaultTargetOptions: {
        shouldOptimize: true,
      },
    });

    await run(b);

    let js = await outputFS.readFile(path.join(distDir, 'index.js'), 'utf8');
    assert(!js.includes('elm$core'));
    assert(js.includes('Elm'));
    assert(js.includes('init'));
  });

  it('should produce correct formatting and indentation when compilation fails', async function () {
    const normalizedPath = normalizePath(
      'test/integration/elm-compile-error/src/Main.elm',
      false,
    );
    await assert.rejects(
      () =>
        bundle(path.join(__dirname, 'integration/elm-compile-error/index.js'), {
          mode: 'production',
        }),

      {
        name: 'BuildError',
        diagnostics: [
          {
            message:
              '\n' +
              `-- TYPE MISMATCH --------------- ${normalizedPath}\n` +
              '\n' +
              'The 1st argument to `text` is not what I expect:\n' +
              '\n' +
              '7|     Html.text 5 "Hello, world!"\n' +
              '                 **^**\n' +
              'This argument is a number of type:\n' +
              '\n' +
              '    **number**\n' +
              '\n' +
              'But `text` needs the 1st argument to be:\n' +
              '\n' +
              '    **String**\n' +

Review comment (suggestion):
I'm sorry, `normalizePath` is actually the other direction (to always use `/`).
This should be `path.normalize('test/integration/elm-compile-error/src/Main.elm')`

Code after:
    let js = await outputFS.readFile(path.join(distDir, 'index.js'), 'utf8');
    assert(!js.includes('elm$browser$Debugger'));
  });

  it('should minify Elm in production mode', async function () {
    let b = await bundle(path.join(__dirname, '/integration/elm/index.js'), {
      mode: 'production',
      defaultTargetOptions: {
        shouldOptimize: true,
      },
    });

    await run(b);

    let js = await outputFS.readFile(path.join(distDir, 'index.js'), 'utf8');
    assert(!js.includes('elm$core'));
    assert(js.includes('Elm'));
    assert(js.includes('init'));
  });

  it('should produce correct formatting and indentation when compilation fails', async function () {
    const normalizedPath = path.normalize(
      'test/integration/elm-compile-error/src/Main.elm',
    );
    await assert.rejects(
      () =>
        bundle(path.join(__dirname, 'integration/elm-compile-error/index.js'), {
          mode: 'production',
        }),

      {
        name: 'BuildError',
        diagnostics: [
          {
            message:
              '\n' +
              `-- TYPE MISMATCH --------------- ${normalizedPath}\n` +
              '\n' +
              'The 1st argument to `text` is not what I expect:\n' +
              '\n' +
              '7|     Html.text 5 "Hello, world!"\n' +
              '                 **^**\n' +
              'This argument is a number of type:\n' +
              '\n' +
              '    **number**\n' +
              '\n' +
              'But `text` needs the 1st argument to be:\n' +
              '\n' +
              '    **String**\n' +
              '\n' +
              '__Hint__: Try using **String.fromInt** to convert it to a string?',