# Copyright 2018-2020 Streamlit Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import streamlit as st

st.code("# This code is awesome!")

st.code("")

e2e/scripts/st_code.py
# Copyright 2018-2020 Streamlit Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import streamlit as st

st.code("# This code is awesome!")

st.code("")

code = """
def hello():
    print("Hello, Streamlit!")
"""
st.code(code, language="python")

e2e/scripts/st_code.py
diff --git a/e2e/scripts/st_code.py b/e2e/scripts/st_code.py
index 00e132f393ae..765f05465028 100644
--- a/e2e/scripts/st_code.py
+++ b/e2e/scripts/st_code.py
@@ -17,3 +17,9 @@
 st.code("# This code is awesome!")
 
 st.code("")
+
+code = """
+def hello():
+    print("Hello, Streamlit!")
+"""
+st.code(code, language="python")
diff --git a/e2e/specs/st_code.spec.ts b/e2e/specs/st_code.spec.ts
index 09fa6ab11882..5feaa8ef73fb 100644
--- a/e2e/specs/st_code.spec.ts
+++ b/e2e/specs/st_code.spec.ts
@@ -28,4 +28,8 @@ describe("st.code", () => {
       "This code is awesome!"
     );
   });
+
+  it("highlights syntax correctly", () => {
+    cy.get(".block-container").matchImageSnapshot("syntax_highlighting");
+  });
 });

Add screenshot test for syntax highlighting

